hous
08-30-2006, 04:19 PM
Homies,
I'm just getting into using javascript/DOM to change pages w/o refreshes. I wanted to dynamically change the text in a text node by <a onclick>, like so:
javascript:
function scalerSwitch(){
if(switcher==0){
switcher=1;
document.getElementById('scaler').childNodes[0].nodeValue='Δ';
return;
}
if(switcher==1){
switcher=0;
document.getElementById('scaler').childNodes[0].nodeValue='∇';
return;
}
}
html:
<a id="scaler" href="javascript:void(0);" onclick="scalerSwitch();">∇</a>
Here's the kicker: Those symbols are written in ampersand codes in the script (I can't get them to display like that in this post), but when the script changes the text, it displays as ampersand code instead of the symbol!!
Here's a link to the page: http://gadoosh.com/hous/practice/position.htm
I'm just getting into using javascript/DOM to change pages w/o refreshes. I wanted to dynamically change the text in a text node by <a onclick>, like so:
javascript:
function scalerSwitch(){
if(switcher==0){
switcher=1;
document.getElementById('scaler').childNodes[0].nodeValue='Δ';
return;
}
if(switcher==1){
switcher=0;
document.getElementById('scaler').childNodes[0].nodeValue='∇';
return;
}
}
html:
<a id="scaler" href="javascript:void(0);" onclick="scalerSwitch();">∇</a>
Here's the kicker: Those symbols are written in ampersand codes in the script (I can't get them to display like that in this post), but when the script changes the text, it displays as ampersand code instead of the symbol!!
Here's a link to the page: http://gadoosh.com/hous/practice/position.htm