admin管理员组

文章数量:1415138

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 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?

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 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?

Share Improve this question asked Apr 12, 2011 at 9:53 SpidermanSpiderman 10k13 gold badges50 silver badges56 bronze badges 1
  • The "global" onload event triggers only after everything is loaded, and this includes your table cell. What's wrong with that? – user447356 Commented Apr 12, 2011 at 9:56
Add a ment  | 

2 Answers 2

Reset to default 1

You can still use the body's onload, it will fire when the plete 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;

本文标签: htmlLooking for javascript event equivalent to 39onRender39Stack Overflow