0

My code looks like this

in .html

<button type="button" onclick="toggle()" id="toggleButton">more ⇓</button>

.js

function toggle(){
document.getElementById("toggleButton").innnerHTML="less ⇑";}

The button appears in my page with the more text, but clicking the button does not do anything.

In I do have reference

<script src="button.js"></script>

And the name of my javescript file is button.js

1
  • 1
    typo error innnerHTML Commented Feb 14, 2018 at 9:11

2 Answers 2

4

It should be innerHTML not innnerHTML

document.getElementById("toggleButton").innerHTML="less ⇑";
<button type="button" onclick="toggle()" id="toggleButton">more ⇓</button>

Sign up to request clarification or add additional context in comments.

1 Comment

Typo should not be answer, comment place is enough for typo mistake :)
0

Try this ..

<input onclick="toggle()" type="button" value="more ⇓" id=myButton1"></input>

Js:

    function toggle()
    {
        if (this.value=="more ⇓") 
             {this.value = "less ⇑";}
        else 
             {this.value = "more ⇓";}
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.