www.webdeveloper.com
Results 1 to 2 of 2

Thread: Changing variables for currentElement.firstChild.data

  1. #1
    Join Date
    Jun 2011
    Posts
    1

    Exclamation Changing variables for currentElement.firstChild.data

    I am working on a script that allows a link's text to be changed from Show Video to Hide Video and back. However, I can't get this to work, as it changes but won't change back. My script:

    HTML Code:
    <head>
    <script language="javascript"> 
    // I wrote this.  The alert is to see if the var changes.
    var chText = "Hide Video"
    
    function change(){
    if (chText == "Hide Video") {
    var chText = "Show Video";
    }
    else {
    var chText = "Hide Video";
    }
    alert(chText)
    }
    </script>
    <script language="javascript">
    //Not mine. It works fine.
    function changeText(currentElement){
    currentElement.firstChild.data=chText;
    }
    </script>
    </head>
    <body>
    <a href="#" onclick="change(), changeText(this)">Show Video</a>
    </body>

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    is data r/w?
    what's up with minute dom methods for text?

    just use element.innerHTML dude, nodes are a headache.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles