I have html
:
<div class="item" data-value="1">item</div>
And js
:
$('.item[data-value="1"]').data('value', 2');
So, now I have .item
with data-value="2"
, I want get it by jQuery:
$('.item[data-value="2"]')
It returns []
I know that the problem is in the fact, that jQuery changes data values not changing data-value
attribute. I know, that the problem can be solved by using attr
method instead of data
.
But is there any way to get objects by data
with data
changed by data
method?