0

http://jsfiddle.net/samertaha/Y2ULV/
kindly see the visibility sample up here ,
in the first rows of the javascript , they declared some variables , but i couldnt understand why they declared a variable named toggle with no value or type.
thanks.

// Get references to page elements and create a link dynamically
    var intro = document.getElementById('intro'),
        dets = document.getElementById('details'),
        a = document.createElement('a'),
        toggle; <- here i cant figure why they declared toggle ... !!!

the whole example in jsfiddle is an example showing how we can use the visibility css proporty.....

thanks

Edited by samertaha

2
Contributors
2
Replies
15
Views
3 Years
Discussion Span
Last Post by ryantroop
0

forget the first question i understand now why they declared the toggle variable.....
but now i cant understand why they populated the anchor this way :
a.appendChild(document.createTextNode('Hide details'));
why not this way with the innerHTML method ???!!!
a.innerHTML = 'View details';
thanks

0

It's easier to follow what they did in code. They easily could have made the entire anchor tag with innerHTML, but chose to be explicit for the sake of readability.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.