Reputation: 27
for dynamically created check box when it is clicked i want to grab the attribute value.It is working in IE 8,9,10 but not working in IE 11,chrome shows function expected error
<input type=checkbox checked='checked' id='SymptomFailureCodeId' TabIndex='54' style='cursor:pointer;' onclick=ChkClickEvt(this); FailureCodeId="1" >
function ChkClickEvt(Obj) {
alert(Obj.attributes("FailureCodeId"));
}
Upvotes: 0
Views: 798
Reputation: 55200
A better method would be using HTML5 data-* attributes.
Markup
<input type='checkbox' id='SymptomFailureCodeId' data-FailureCodeId="1" />
JavaScript
var article = document.querySelector('#SymptomFailureCodeId'),
data = article.dataset;
console.log( data.FailureCodeId );
P.S: You would be golden with this and this
P.P.S: I am fairly sure that making up custom attributes like that is not the best practice. I am searching for further evidence to back my argument. ;)
Upvotes: 0
Reputation: 27765
Try using getAttribute
instead:
Obj.getAttribute("FailureCodeId")
Or if you want to use attributes
property don't use it as a method. It's a NamedNodeMap
.
For example:
Obj.attributes["FailureCodeId"]
But be aware that this no longer supported on Firefox > 22 and many modern browsers. Read more about this at MDN
Upvotes: 1