I have some dynamic content that gets published in a <span> of ID "giftopt". There can be any number of these <span> tags with ID = "giftopt". Is there a way with jQuery to check the text in ALL the <span></span> tags with ID = "giftopt" until it finds the word I am looking for or doesn't at all?
I would like to write a conditional statement that:
var giftopt = jQuery(\"#giftopt\").text(); if (giftopt == 'Someone Else') { jQuery(\".warning\").show('slow'); }
});
</script>
My inital test seems that it will check until it comes to the first class with ID "giftopt", but it is highly likely that the first one won't have the text I am looking forward and I need it to continue to see if there is any other classes with ID = "giftopt".
ID's are UNIQUE, especially when it comes to JavaScript. You'll need to use a CLASS name of "giftopt" if there are going to multiples on the page that you need to target all as a group.
I would like to write a conditional statement that:
My inital test seems that it will check until it comes to the first class with ID "giftopt", but it is highly likely that the first one won't have the text I am looking forward and I need it to continue to see if there is any other classes with ID = "giftopt".
Any help?
So I use a class...
How do I parse them all to see if any of them contain a certain text?
a simple example would be
$(document).ready(function() {
$('span:contains(the word you are looking for)').do what you want from here('');
});
Is this going to check "ALL" Span's" tags on the page or just the first one it finds as in my experience (my the cord I included)?