I was analyzing a plugin but I realize the author uses:
$('<div/>').addClass('sample-piece');
instead of the following
$('div').addClass('sample-piece');
what is the meaning of <div/>
, <a/>
...... it doesn't seem to be a valid html tag.
I can't seem to find any solution for this as google doesn't allow me from searching operator online.....
$('<div/>').addClass('sample-piece');
create a newdiv
element and add classsample-piece
to it. The new created div is not in the dom tree at that time, you may need to append it to some other element.$('div').addClass('sample-piece');
add classsample-piece
to the all thediv
elements in the dom tree.summarize:
$('<div/>')
creates a newdiv
element.$('div')
selects all thediv
elements.