dzhax Posted December 23, 2009 Share Posted December 23, 2009 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 More sharing options...
Greywacke Posted December 23, 2009 Share Posted December 23, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.