Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    92
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Jquery: Selecting all with a certain class

    Hey, is it possible to select all the elements with a class containing the text "lm". So, stuff can have the class lm2 or lm9 and those objects will be selected?

    I tried:

    Code:
    $("e.attr('class'):contains('lm')")

  • #2

  • Users who have thanked Bill Posters for this post:

    spetsacdc (12-06-2008)

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    92
    Thanks
    19
    Thanked 0 Times in 0 Posts
    Thanks, I forgot about that.

    Now, is there anyway to select the name of a class that contains "lm"?

    I can do it using jquery to select all the classes of something that has "lm#z" as one of them. However, I have to use string manipulation to get the class name that starts with lm and ends with z

    Code:
    var all_classes = $(e).parents(".div_row[class*='lm']").attr("class");
    the_class = all_classes.substring(all_classes.indexOf("lm"),all_classes.indexOf("z")+1);
    Thanks

  • #4
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    You can use CSS to do that:
    Code:
    <style>
    p[class^="lm"][class$="z"] {...}
    </style>
    Above selects any element P which has its class attribute starting with 'lm' and ending with 'z'. Of course this selection is only useful for styling.

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by freedom_razor View Post
    You can use CSS to do that:
    Well, you could if the world's second most popular browser supported it.

    Using js is likely to be the most widely supported approach.

  • #6
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    Second most popular browser would be IE7, and it supports it. If you thinking about IE6, possibly it doesn't. I don't know, I don't use IE6 for testing and pages I make are not available for users of IE6 and lower. The sooner IE6 dies out, the better for all of us

  • #7
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by freedom_razor View Post
    Second most popular browser would be IE7
    That depends on whose stats you're looking at.
    W3Schools will tell you 20%, whilst thecounter will tell you 35%

    IE6 has 20%+ of the (non-niche) market, which is more than enough to warrant support by any site wishing to reach users.

    Not insignificantly, Yahoo still consider IE6 a browser worthy of A-Grade support - which, one presumes, is based on their own stats which are likely to give a good picture of the general browser share situation.

    If you thinking about IE6, possibly it doesn't. I don't know
    If you're creating website for money, you should know.
    It doesn't support attribute selectors. Now you do know.

    I don't use IE6 for testing and pages I make are not available for users of IE6 and lower.
    Forgive me for asking, but do you have any (proper) clients?
    If so, are they happy that their sites 'are not available' to around 20%+ of (general) users?
    Last edited by Bill Posters; 12-18-2008 at 12:49 PM.

  • #8
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    I don't make websites for money. Paid developer probably couldn't [unless asked to] make a website inaccessible to IE6 users on purpose. By 'not available' in my previous post I meant - if you visit it with IE6 or lower, only thing you get is an advice to upgrade your browser. Without going another mile off topic, if you wish to know my reasons for having 20% less visitors, feel free to PM me.
    P.S. Linked sites are not mine, just show what I agree with.

  • #9
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by freedom_razor View Post
    I don't make websites for money.
    I guessed as much.
    I, on the other hand, do - which means, for better or worse, I need to put what my clients' aims ahead of desires to make my life that little bit easier (though I get paid for the time I spend fixing things in IE6 as well, so…)

    (I've not had major problems bringing IE6 into line for some years. I may not end up with identical sites, effects, full features for IE6, but I sure as hell don't give them a page telling them to upgrade. The key is progressive enhancement, not to fob off that many users with an upgrade notice.)

    Don't get me wrong. I'm as in love with web standards and resentful of IE6 as the next standardista. There are few things I'd like more (for my working day) than to see IE6 suddenly disappear from face of the earth. But, back in the real world, where ditching ~20-35% could literally mean losing out on millions in revenue for clients, my desire to ignore IE6 users isn't likely to find parity amongst my clients.

    Consequently, it's most often those with few, if any, clients who enjoy the luxury of drawing lines in the sand, saying that they don't and won't support IE6. Professionals are too busy just getting on with it.
    Last edited by Bill Posters; 12-18-2008 at 08:12 PM.

  • #10
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    Lol @ this thread. Part of the fun in development is finding ways to make your design appear exactly the same on everybody's screen (whether that means browser, resolution, flash, whatever).

    Without that challenge I'd be bored out of my mind.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com


  •  

    Posting Permissions

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