Handy addClass use in .append
- $('body').append('<div id="mydiv"></div>).addClass('newClass');
addClass can be used to add a class to a selector. Take the above example. If the class is added to 'mydiv' instead, not body, this could be handy than writing the two lines:
- $('body').append('<div id="mydiv"></div>);
- $('#mydiv').addClass('newClass');