The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to use jQuery to parse all the classes with name/ID of?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #23417

    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:


    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?


    Thats fine.

    So I use a class…

    How do I parse them all to see if any of them contain a certain text?


    No one knows how?


    to see if a span contains something you can check with a $(‘span:contains(the word you are looking for)’)

    a simple example would be

    $(document).ready(function() {

    $(‘span:contains(the word you are looking for)’).do what you want from here(”);



    Thanks Pab.

    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)?

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.