JQuery Can we capture both p and div tags at a time in the same sentence using jquery?

JQuery Can we capture both p and div tags at a time in the same sentence using jquery?

+5
source share
2 answers

Use a comma selector:

$("div, p")...

or add():

$("div").add("p")...
+4
source

......

$('p, div')..........

Just separate each element with a comma ( ,).

Alternatively, you can use the add function :

$('p').add('div')..........
+3
source

All Articles