scm0sml
asked on
changing button text with javascript
Hi,
I have the javascript function below. The line:
document.getElementById(bu tton).inne rtext = '-';
isn't working.
What am I doing wrong?
I have the javascript function below. The line:
document.getElementById(bu
isn't working.
What am I doing wrong?
function showhiderow(id,button) {
if (document.getElementById) {
if (document.getElementById(id).style.display == 'none')
{
document.getElementById(id).style.display = 'block';
document.getElementById(button).innertext = '-';
}
else
{
document.getElementById(id).style.display = 'none';
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It depends where the button label is written.
<button type="button" id="myButton2">Button Label</button>
- .innerHTML or better .childNodes[0].nodeValue
or
<input type="button" value="Button Text" id="myButton1"></input>
- .value
http://www.permadi.com/tutorial/jsInnerHTMLDOM/index.html
<button type="button" id="myButton2">Button Label</button>
- .innerHTML or better .childNodes[0].nodeValue
or
<input type="button" value="Button Text" id="myButton1"></input>
- .value
http://www.permadi.com/tutorial/jsInnerHTMLDOM/index.html
Hi,
I believe that you should use document.getElementById(bu tton).valu e instead ov document.getElementById(bu tton).inne rtext .
Good luck!
I believe that you should use document.getElementById(bu
Good luck!
document.getElementById(bu