Forums

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

Home Forums JavaScript Making changes based on the content of a TD

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #207242
    amidigital
    Participant

    I have a table that is generated by a wordpress plugin. And the writers change it constantly.

    Is there anyway to say “If this TD contains a number between 4 and 8 apply this CSS class to it.”

    Thanks

    #207247
    Shikkediel
    Participant

    Sure, jQuery has addClass and removeClass. Combined with some more JS you could switch classes with that.

    #207252
    Paulie_D
    Member

    I don’t think JQ can natively compare numbers…but probably with raw JS?

    I did a quick search in SO and came up with

    http://stackoverflow.com/questions/21685682/detecting-number-range-in-class-td-div-change-css-jquery

    which seems bang on point.

    JSfiddle

    #207274
    amidigital
    Participant

    Thanks that works perfect when I built it on SO. However when I move it to the site it is not working.

    My SO

    My Site

    #207276
    amidigital
    Participant

    Nevermind, worked when I moved it to the footer.
    Thanks!

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