$(#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')
而不是 - ?
$(#id).attr('class')
.