SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select elements that don't have certain classes

    I have a jQuery script that changes the background color of odd rows in a table. If a row has class "new", though, it won't change it:

    Code:
    $(document).ready(function() {
    	$('tr[class!=new]:odd').css({'background-color':'#ddd'});
    });
    Is it possible to specify another class (together with "new") to which the script should not change the color? If yes, what's the syntax?

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,107
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Hi,

    Assuming it works according to spec here's how you specify multiple attributes in a selector.
    Selectors
    Code css:
    span[hello="Cleveland"][goodbye="Columbus"] { color: blue; }

  3. #3
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by markbrown4 View Post
    Hi,

    Assuming it works according to spec here's how you specify multiple attributes in a selector.
    Selectors
    Code css:
    span[hello="Cleveland"][goodbye="Columbus"] { color: blue; }
    It works

    Thank you very much!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •