Find 2 date attributes in a single element

5

How can I find a particular attribute that contains another specific attribute attribute? for example:

<a class="fc-draggable" data-belongs="3" data-target="2"></a>

I can select all elements that contain a given attribute using:

$('*[data-belongs="3"]');

But how do I select all data-belongs='2' that contains data-target='3' ?

    
asked by anonymous 23.09.2016 / 20:47

2 answers

3

You can use $('[data-belongs="2"][data-target="3"]'); as I mentioned in comment , so you look for elements with both attributes.

To select through element attributes we can use the attribute selectors next to each other.

To filter later we can use .not() like this:

$('a[data-belongs]').not('[data-belongs="' + nr + '"][data-‌​target="' + nr + '"]‌​').hide();

Example: link

    
24.09.2016 / 07:03
4

Try this:

$('*[data-belongs="2"][data-target="3"]');

Source: jQuery: Multiple Attribute Selector

    
23.09.2016 / 22:35