Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-06-2008, 01:11 AM   PM User | #1
spetsacdc
New Coder

 
Join Date: Mar 2008
Posts: 92
Thanks: 19
Thanked 0 Times in 0 Posts
spetsacdc is an unknown quantity at this point
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')")
spetsacdc is offline   Reply With Quote
Old 12-06-2008, 09:23 AM   PM User | #2
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
http://docs.jquery.com/Selectors/att...attributevalue
http://docs.jquery.com/Selectors/att...attributevalue
Bill Posters is offline   Reply With Quote
Users who have thanked Bill Posters for this post:
spetsacdc (12-06-2008)
Old 12-06-2008, 05:13 PM   PM User | #3
spetsacdc
New Coder

 
Join Date: Mar 2008
Posts: 92
Thanks: 19
Thanked 0 Times in 0 Posts
spetsacdc is an unknown quantity at this point
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
spetsacdc is offline   Reply With Quote
Old 12-18-2008, 09:06 AM   PM User | #4
freedom_razor
Regular Coder

 
Join Date: Dec 2008
Location: Tannhäuser Gate
Posts: 286
Thanks: 7
Thanked 58 Times in 57 Posts
freedom_razor is an unknown quantity at this point
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.
freedom_razor is offline   Reply With Quote
Old 12-18-2008, 09:36 AM   PM User | #5
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
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.
Bill Posters is offline   Reply With Quote
Old 12-18-2008, 11:23 AM   PM User | #6
freedom_razor
Regular Coder

 
Join Date: Dec 2008
Location: Tannhäuser Gate
Posts: 286
Thanks: 7
Thanked 58 Times in 57 Posts
freedom_razor is an unknown quantity at this point
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
freedom_razor is offline   Reply With Quote
Old 12-18-2008, 11:44 AM   PM User | #7
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
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.

Quote:
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.

Quote:
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 11:49 AM..
Bill Posters is offline   Reply With Quote
Old 12-18-2008, 12:53 PM   PM User | #8
freedom_razor
Regular Coder

 
Join Date: Dec 2008
Location: Tannhäuser Gate
Posts: 286
Thanks: 7
Thanked 58 Times in 57 Posts
freedom_razor is an unknown quantity at this point
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.
freedom_razor is offline   Reply With Quote
Old 12-18-2008, 03:19 PM   PM User | #9
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
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 07:12 PM..
Bill Posters is offline   Reply With Quote
Old 12-18-2008, 06:23 PM   PM User | #10
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
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
itsallkizza is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:09 AM.


Advertisement
Log in to turn off these ads.