Reputation: 1677
Following code is working in Chrome but not working in IE
repNumObject = document.querySelector("input[type='radio']:checked");
It is throwing error of invalid argument in try catch block please suggest solution
Upvotes: 1
Views: 1645
Reputation: 2799
document.querySelector in IE8 only recognized CSS 2.1 selectors and non special tags (html5 tags like section or article). To avoid this asap, you could use some library like jQuery: http://jquery.com/
Upvotes: 0
Reputation: 388316
I think the problem is the :checked selector, which is not supported in IE8
var els = document.querySelectorAll("input[type='radio']");
//need to loop els and find the checked item
for (var i = 0; i < els.length; i++) {
if (els[i].checked) {
repNumObject = els[i];
}
}
Upvotes: 4