$(#id).className jQuery not working in IE9

i am trying to get className of a tag using its ID. These TR tags are generated using ASP response.write, and the jquery is written inside a function which will be called on button click and this button is a TD inside the same row which pass rowid as parameter. I am not sure what is going wrong as it works fine with IE7,IE8 and IE9 compatibility mode.

Please help me to get though this.

Following is are my codes

JS:

function rowvalue(id){
    var namecls = $("#tabrow" + id).className;
}

ASP:

response.write "<TR id="tabrow" & rid & " class=""Row" & (Cn) & """>"
response.write "<TD>"
response.write "<BUTTON onclick=""Javascript:rowvalue(" & ID & ")"">Edit</BUTTON></TD>"
response.write "</TD>"
response.write "</Tr>"

Use

$('#id').attr("class")

That should work. It fetches the value from the "class" attribute.

Possibly interesting, there are also some class-related functions that can come in handy: http://api.jquery.com/category/manipulation/class-attribute/


试试$(#id).attr('class')而不是 - ?


  • It's not jQuery related, className is a DOM attribute and it works in IE9 PR3
  • Use $(#id).attr('class') .
  • 链接地址: http://www.djcxy.com/p/36524.html

    上一篇: UpdatePanel中的CustomValidator奇怪地在IE9中工作

    下一篇: $(#id).className jQuery不能在IE9中工作