hasClass « addClass « jQuery Q&A

Home
jQuery Q&A
1.addClass
2.alert
3.array
4.attribute
5.browser
6.callback
7.clone
8.Cookie
9.Date
10.Development
11.document
12.dom
13.element
14.filter
15.Firefox
16.flash
17.format
18.html
19.input
20.internet explorer
21.json
22.mootools
23.page
24.performance
25.regex
26.safari
27.selector
28.setTimeout
29.String
30.table
31.Text
32.trigger
33.URL
34.video
35.xml
jQuery Q&A » addClass » hasClass 

1. If hasClass then addClass to parent    stackoverflow.com

Original post: Why doesn't this simple script work?

if ($('#navigation > ul > li > ul > li > a').hasClass('.active')) {
    $(this).parent().parent().parent().addClass(".active");
}
EDIT: This won't hide the H1:
if ($('#content h1').hasClass('aktiv')) {
  ...

2. each() within each() and addClass within hasClass somehow doesn't work    stackoverflow.com

Yet another head scratcher, this one! Why does everything in the below work, except for the ONE addClass() line?

var arr = ['1000','1001','1002','1003','1004','1005'],
    allarr = 0;

$.each(arr, function(i, value) {
 ...

3. jQuery hasClass / addClass Issue    stackoverflow.com

This is what I have. The li has a class of current but for some reason it's not adding the class.

if (jQuery("#sidebar li").hasClass("current")) {
        ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.