I try to remove a specific select element with attibute value called data-wr. So then I can remove it from the dom.
Html:
<div class='tcat'>
<select>..</select>
<select data-wr="1">..</select>
<select>..</select>
<select data-wr="12">..</select>
<select data-wr="3">..</select>
</div>
Below JQuery removes all the select elements:
var rw= 12;
$('select[data-wr != ' + rw + ']')
But it has to be equal to rw's value:
var rw= 12;
$('select[data-wr = ' + rw + ']')
above does not work.
I also tried from this question: jQuery how to find an element based on a data-attribute value?
var s = $(".tcat").find("select[data-wr='" + rw + "']");
s.remove();
also filter isn't working:
var s =$('.tcat').find($('select').filter('[data-wr=' + rw + ']'))
I could not make it work.