Я написал код jQuery для получения атрибута из тега TR в html. Код работает в IE 8, но когда я запускаю его в IE 9, я получаю сообщение об ошибке «Ожидается функция». Код ниже:
$(".grid tr").each(function () { //I've inserted an attribute called idRow in each grid row. if(this.attributes("idRow") != null) //I get the "Function expected error" here { ... } });
В чем проблема кода? Почему это работает в IE 8?
Как насчет
if($(this).attr('idRow') != undefined) { ... }
Чтобы принять такой подход, вам нужно ...
this.attributes.getNamedItem('idRow').nodeValue
или ...
this.attributes.item('idRow').nodeValue
... хотя, я бы предложил простоиспользуя getAttribute().
getAttribute()
this.getAttribute('idRow')
Я бы лучше использовал
$(".grid tr").each(function (tr) { //I've inserted an attribute called idRow in each grid row. if(tr.attributes("idRow") != null) //I get the "Function expected error" here { ... } });