开发者

Looking for javascript event equivalent to 'onRender'

I'd like to add to my <td> element JS event listener that will be triggered when the page is rendered (or loaded) to the DOM and the TD contains its innerHTML value. something like:

<script>
function开发者_C百科 manipulate(field){
field.value = field.value+'_done';
}
</script>
<td onRender=manipulate(this)>Hello World</td>

I can't use onLoad because it can be used in <body> only to my understanding Is there any way to do it?


You can still use the body's onload, it will fire when the complete page is ready and loaded. You can set an attribute for every TD element you'd like to manipulate, and then traverse the page to find those elements and call your function.

Why do you want to manipulate something after the DOM is loaded?


You don't have to attach the onLoad event to the body. You can use the global event handler like this:

function init() {
 //Your function call
}
window.onload = init;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜