Jump to content

Events


dzhax

Recommended Posts

i have code that uses ajax to insert text into an area with the onclick event. Now I was wondering if there is a way to determine if the area contains text and if so remove it upon reclicking the same object?I am using the id paramater of <td> tags to insert data.

Link to comment
Share on other sites

if (document.getElementById("tdid").innerHTML.length > 6) {  document.getElementById("tdid").innerHTML = " ";}

okay it can't be truly empty otherwise it would not display. this is the best solution as far as i know, you can even do that in one line other than in a function if you need to, in an html onclick event.if clicking the td to clear it and the onclick event is in the td, the code can be shortened - by using "this" instead of "document.getElementById('tdid')". not completely clear on where you would want to use this code.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...