Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

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

like image 376
user291221 Avatar asked Mar 11 '10 06:03

user291221


2 Answers

Use the comma selector:

$("div, p")...

or add():

$("div").add("p")...
like image 84
cletus Avatar answered Oct 03 '22 06:10

cletus


......

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

Just separate each item with a comma (,).

Alternatively, you could use the add function:

$('p').add('div')..........
like image 42
Sarfraz Avatar answered Oct 03 '22 06:10

Sarfraz