What’s the difference between $.add and $.append JQuery

They are not at all related.

.add()

Add elements to the set of matched elements.

e.g.

If you want to do,

$('div').css('color':'red');
$('div').css('background-color':'yellow');
$('p').css('color':'red');

Then, you can do,

$('div').css('background-color':'yellow').add('p').css('color':'red');

Reference

.append()

Insert content, specified by the parameter, to the end of each element in the set of matched elements.

$('div').append('p');

will append selected p on all selected div in dom.

Reference

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)