Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate jQuery objects?

$.and?

so I have a var that containssome jquery object which contains some elements (in this case <a> elements)

var elements = $('a');

I then want to add some other elements (in this case <b> elements) to this string when using a click function for instance...

elements.and('b').on("click", function(){
    //some random code
});

Any way to do this?

like image 743
lededje Avatar asked Nov 29 '12 12:11

lededje


1 Answers

Are you looking for add ?

elements.add('b')....

Note that $('a, b'); would do too.

like image 145
Denys Séguret Avatar answered Oct 05 '22 17:10

Denys Séguret