lboyel
lboyel

Reputation: 2228

Target elements with different ids Jquery

How do I target a particular element used with different ids.For instance that have the ids row and col. I have tried doing this with jquery.

var $drag = $( "#col" );
var $drag2 = $( "#row" );
$("td", $drag, $drag2).droppable({ accept: ".special" });

But the second id "row" stored in drag2 is not selected. What is the proper way of doing this in jquery.

Upvotes: 0

Views: 63

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388406

You can use multiple selector

$( "#col, #row" ).find("td")

or

var $drag = $( "#col" );
var $drag2 = $( "#row" );
$drag.add($drag2).find("td").droppable({ accept: ".special" });

Upvotes: 3

Related Questions