Is it possible to select an element based on a value set on its data attribute?
For example, I thought I could use:-
$("div").find("[data-btn='1']").css({'background-color':'#232323'});
Open in new window
So, if I had multiple elements such as:-
<div data-btn="1">1</div>
<div data-btn="2">2</div>
<div data-btn="3">3</div>
<div data-btn="4">4</div>
<div data-btn="5">5</div>
Open in new window
It would set the first element to have the background colour.
The idea eventually is be a bit more dynamic with the data value, so something like:-
$("div").find("[data-btn='" + $(this).val() . "']").css({'background-color':'#232323'});
Open in new window
But, Im just seeing if this is possible first.
eg
https://jsfiddle.net/8yansth1/Any ideas???