0
var $parent = $('<p>').addClass('exanple-class').prop('id','id-parent').appendTo('body'); 

I partially understand the statement above, but why declare the variable prefixed with dollar sign ? Why not use var parent = somecode, I've searched and cant find a definition

Rory McCrossan
  • 319,460
  • 37
  • 290
  • 318
Jeter2015
  • 3
  • 2

1 Answers1

2

It's somewhat of a convention. It lets you know, without having to go back to check where the variable was declared, that it contains a jQuery object.

Adam
  • 46,658
  • 11
  • 63
  • 84