Reputation: 57
I have a webpage which contains while loop, i have assign an id to each element inside the while loop, here is an example:
< tagname id="show_div_1">< /tagname>
The "show_id_" is static but "1" is dynamic which comes from loop and it will be increase to 2,3,4 ...etc.
Anyone knows how to select such elements using javascript or jquery?
Or is there any alternative way to do so?
Upvotes: 0
Views: 36
Reputation: 60007
Why not just put them in the same class?
i.e.
<tagname class="something">
then
$(.something)
Upvotes: 2
Reputation: 31787
You can use the Jquery contains selector
Like this
$('tagname[id*="show_div_"]').each(function() {
// ...
});
Upvotes: 1