I have a list kind of like below:
<p class='info' data-info='1'>Info 1 <span class='status'></span></p>
<p class='info' data-info='2'>Info 2 <span class='status'></span></p>
<p class='info' data-info='3'>Info 3 <span class='status'></span></p>......etc
What I need to do is run through all the .info elements and if the data-info number is included in an myArray change the span text. How, in jQuery do I match a value from inside an array ?
$('.info').each(function() {
$this = $(this);
if ($.inArray($this.data('info'), myArray) !== -1) {
$this.children('.status').text('New text value');
}
});
Here's a fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With