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
  • 331,213
  • 40
  • 305
  • 339
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 Jenkins
  • 51,445
  • 11
  • 72
  • 100