CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   Jquery: Selecting all with a certain class (http://www.codingforums.com/showthread.php?t=153712)

spetsacdc 12-06-2008 01:11 AM

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')")

Bill Posters 12-06-2008 09:23 AM

http://docs.jquery.com/Selectors/att...attributevalue
http://docs.jquery.com/Selectors/att...attributevalue

spetsacdc 12-06-2008 05:13 PM

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

freedom_razor 12-18-2008 09:06 AM

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.

Bill Posters 12-18-2008 09:36 AM

Quote:

Originally Posted by freedom_razor (Post 761046)
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.

freedom_razor 12-18-2008 11:23 AM

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

Bill Posters 12-18-2008 11:44 AM

Quote:

Originally Posted by freedom_razor (Post 761088)
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?

freedom_razor 12-18-2008 12:53 PM

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.

Bill Posters 12-18-2008 03:19 PM

Quote:

Originally Posted by freedom_razor (Post 761105)
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.

itsallkizza 12-18-2008 06:23 PM

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.


All times are GMT +1. The time now is 03:58 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.