Monday, April 25, 2011

jQuery Problem with class attribute: Why does this work in 1.2.6 and doesn't on 1.3.1?

Hi everyone!!

Well... for me it's just the same thing, but I don't know why this works in 1.2.6 and doesn't in 1.3.1:

if ($('.trSelected').length == 2)
{
        alert("hello");

}

In this case, I'm selecting rows on flexigrid and used to work just fine in 1.2.6.

To work in 1.3.1, I had to do this:

if ($('#flexDiv .trSelected').length == 2)
{
           alert("hello");

}

I had to specify the table from where the trSelected are... why does this happens?? I'm having too many problems with class attibutes. For example: If I have 3 input text with class "test", only the first input text is functional... the other ones no. Why? thanks!!!

From stackoverflow
  • Did you debug what does the $('#flexDiv .trSelected').length return ?

    Best thing for javascript debugging is Firebug.

    In javascript write:

    console.log(  $('#flexDiv .trSelected').length  );
    

    And then look in your Firebug console what do you get.

    Ben Blank : You can also write `$('#flexDiv .trSelected').length` directly in the Firebug console without modifying your script. Firebug is available as a bookmarklet for non-Firefox browsers.

0 comments:

Post a Comment