purencool Posted August 20, 2010 Share Posted August 20, 2010 Hi phpfreaks can anyone tell why this if statement won't work? all I want it to do is read the id and the contents inside the td that is called altSwitch and then if it equals 0 then change it to a On <td>Alt</td><td id="altSwitch">0</td> I have tried this <script type="text/javascript"> if (document.getElementById("altSwitch").element.nodeValue=="0"){ document.getElementById("altSwitch").innerHTML="On";} </script> and this <script type="text/javascript"> if (document.getElementById("altSwitch").element.innerHtml=="0"){ document.getElementById("altSwitch").innerHTML="On";} </script> Link to comment https://forums.phpfreaks.com/topic/211248-if-statement-for-id-wont-work/ Share on other sites More sharing options...
brianlange Posted August 20, 2010 Share Posted August 20, 2010 use firstChild in place of where you have element document.getElementById("altSwitch").firstChild.nodeValue=="0" Link to comment https://forums.phpfreaks.com/topic/211248-if-statement-for-id-wont-work/#findComment-1101763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.