Reputation: 1059
I'm trying to find <body onload="function();">
and replace it with <body>
on onClick
event.
Any suggestions how this could be done?
Thank you.
UPD.
Sorry for an unclear question. Crozin answered my question, I was just trying to remove onload
attribute.
Upvotes: 0
Views: 2205
Reputation: 44406
Do you want to search and replace String or DOM Element? If string then use this:
var str = "....<body onliad=\"function();\">....";
var replaced = str.replace("<body onload=\"function();\">", "<body>");
If you want to delete onload
attribute from DOM element use this:
document.body.removeAttribute("onload");
Upvotes: 1