Jump to content

if statement for id won't work


purencool

Recommended Posts

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

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.