Skip to content Skip to sidebar Skip to footer

How To Add More Than One Selector In Javascript

How can i add more the one variable in JavaScript : var selector = 'a[href$=png]:has(img)'; So that it can get images with other format like jpg, jpeg and bmp also. Full script ht

Solution 1:

You can use multiple selectors in the same statement to select anything that matches either of your selectors, like so:

$('.selector1, .selector2')

This will match any element with the class selector1 or selector2. Therefore you could try something like the following:

var selector = 'a[href$=png],a[href$=jpg]';
$(selector)...

Post a Comment for "How To Add More Than One Selector In Javascript"