Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5997535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:16:39+00:00 2026-05-23T00:16:39+00:00

I am having, <tr valign=top> <th class=chkCol fixed>..checkbox..</th> <th class=fixed>..head..</th> </tr> Now in Jquery

  • 0

I am having,

<tr valign="top">
    <th class="chkCol fixed">..checkbox..</th>
    <th class="fixed">..head..</th>
</tr>

Now in Jquery I am calling a function like,

if($(this).hasClass("fixed")){
   ....
}

If I call $(this).hasClass("fixed"), then I need to get only head not checkbox and that is working perfect in Jquery 1.4.2 but now I updated to jquery 1.6.1.
Now I am getting checkbox inside if condition.

Please Help,

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:16:40+00:00Added an answer on May 23, 2026 at 12:16 am

    I’d be very surprised if jQuery 1.4.2 gets this wrong jQuery 1.4.2 does not get this wrong. hasClass("fixed") should be true in both cases, in all versions of jQuery. Here’s an example using v1.6.1, and the same example using v1.4.2. Both work fine.

    If you want to check that “fixed” it’s the only class on an element, that’s more easily done without jQuery, by going directly to the reflected property:

    if (this.className === "fixed") {
        // ...
    }
    

    className is a property reflecting the “class” attribute, and like the “class” attribute it’s a space-delimited string.

    The above will fail, of course, if the element has any other class on it as well, like “fixed something-else”.

    If you specifically want to check it has “fixed” and doesn’t have “chkCol”, then you have to do that on purpose:

    var $this = $(this);
    if ($this.hasClass("fixed") && !$this.hasClass("chkCol")) {
        // ...
    }
    

    If you were doing this in a selector (rather than checking an element you already had) you could use the selector ".fixed:not(.chkCol)". But although you can do that with an element you already have using is, it’s unnecessarily expensive (jQuery has to parse the selector).


    Update: You’ve said that you’ve tried the && !$this.hasClass("chkCol") thing and it hasn’t worked. That means that something earlier in the if condition has already determined the outcome of the expression as a whole, and so the result of the !$this.hasClass("chkCol") part makes no difference (and isn’t getting run at all, as JavaScript short-circuits expressions).

    Example:

    var x = 1;
    
    if (x == 1 || $this.hasClass("fixed") && !$this.hasClass("chkCol"))
    

    In that case, because x is 1, nothing to the right of the || is even looked at at all; the expression’s value is already true.


    Update 2:

    You’ve said you’re using hasClass, but in a comment on another answer you said:

    If i use $(this).attr('class') == "fixed", then not at all going into if condition

    I don’t suppose what you’re actually doing is this:

    if ($(this).attr('className') == "fixed") {
        // ...
    }
    

    Note that’s “className”, not “class”. If that’s what you’re doing, that will not work on 1.6.1 but it will on 1.4.2. There is no attribute called “className”; there’s an attribute called “class” and a property called “className”. jQuery 1.6.x differentiates between attributes and properties.

    My code above, using hasClass, will work on all versions. Or change your code to use attr("class") rather than attr("className").

    Here’s a v1.4.2 example showing attr("className") working (which it shouldn’t). Here’s a v1.6.1 example showing attr("className") not working (which is correct). Both versions show the correct way to get at the “class” attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting a td to have some text at its top and
Having an array of N sets, what is the fastest way to generate the
Having more than one process read from a serial device (/dev/ttyXX) makes it so
Having a problem while passing messages using content scripts in Google chrome extension dev
Having spent a bunch of time recently doing 2D work that involves pixel manipulation
Having a bit of a problem with mysql... Mysql 5.1 on windows 2008 server
Having multiple indices for an SQL table, is there a way to know what
I want to remove the title area section which is above view all site
I've trying to submit html emails to amazon's mechanical turk using the questionform xml
I am working on dynamic form. i have a radio button, if a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.