How can I select all elements whose id
starts with "player_"?
I have multiple elements like this:
<div id="player_290x3dfda">text</div>
Every id
has a unique stamp on it. How can I select all those elements, either with jQuery or with pure CSS?
This question is related to
jquery
css
jquery-selectors
css-selectors
$('div[id ^= "player_"]');
This worked for me..select all Div starts with "players_" keyword and display it.
You can use meta characters like *
(http://api.jquery.com/category/selectors/).
So I think you just can use $('#player_*')
.
In your case you could also try the "Attribute starts with" selector:
http://api.jquery.com/attribute-starts-with-selector/: $('div[id^="player_"]')
try this:
$('div[id^="player_"]')
Source: Stackoverflow.com