Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery find by two attr values

Tags:

jquery

I have table cells with attributes data-position-x and data-position-y with integer values. I want to find one certain cell by x and y values. Is it possible in jQuery? At the moment I can't figure out how I can pass two predicates to construction $('[data-position-x="0"]');

like image 881
Nik Avatar asked Jul 09 '12 19:07

Nik


People also ask

How get multiple data attribute values in jQuery?

var data = $(". menu-data"). attr("data-title");

Can we use multiple selectors in jQuery?

You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order.

What is attribute selector in jQuery?

The [attribute] Selector is an inbuilt selector in jQuery, used to select all the elements with the specified attribute. Syntax: $("[attribute_name]") Parameter: attribute_name: It is the required parameter which specify the attribute to be select.


1 Answers

The multiple attribute selector is what you are looking for:

$('[data-position-x="0"][data-position-y="0"]');
like image 66
Jeff Jenkins Avatar answered Sep 19 '22 15:09

Jeff Jenkins