Am trying to add an attr for the id and onclick, its working on firefox and chrome but for some reason it isn't working on IE 9 . Any alternative or something is wrong with me code?
$(".extendedGridView tr td a").each(function (index)
{
if ($(this).html() == "Update")
{
$(this).attr('id', 'insertButton');
$(this).attr('onclick', "return Validate('extendedGridView')");
}
});
Don't use attr for this. Use
this.id = 'insertButton';
$(this).click(function(){return Validate('extendedGridView')});
Note also that checking a text using html() isn't going to work if there are returns or space or any tags. Prefer this test :
if ($(this).text().trim() == "Update") {
Then, be sure to have a different id for each element. It's unclear in your code if you're OK on this point but as you're using each
, I'm afraid it's not. If what you need is to make your elements selectable more easily, use a class :
$(this).addClass('update');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.