Both of your if
statements are getting executed one after each other, as you change the value and then immediately read it again and change it back:
function toggle(button) { if(document.getElementById("1").value=="OFF"){ document.getElementById("1").value="ON";} else if(document.getElementById("1").value=="ON"){ document.getElementById("1").value="OFF";} }
Adding the else
in there should stop this happening.
Related Posts:
- Edit webpage with javascript trick – how to “unedit”?
- Automatically pausing html5 video as the ‘next’ button is pressed (javascript/ jquery)
- Is it possible to write data to file using only JavaScript?
- Remove CSS class from element with JavaScript (no jQuery) [duplicate]
- Is it possible to write data to file using only JavaScript?
- How to make JavaScript execute after page load?
- Set cookie and get cookie with JavaScript
- Which is better: or
- Onclick javascript to make browser go back to previous page?
- How to make JavaScript execute after page load?
- Why is my Javascript not working?
- How can I get the values of data attributes in JavaScript code?
- Javascript: getElementById vs getElementsById (both works on different pages)
- mailto using javascript
- mailto using javascript
- Mailto using Javascript?
- How to change css property using javascript
- javascript close current window
- How to call a JavaScript function within an HTML body
- How to save user input into a variable in HTML and JavaScript
- Hiding a button in Javascript
- Show/hide ‘div’ using JavaScript
- How to make JavaScript execute after page load?
- Get HTML code using JavaScript with a URL
- Calculate percentage Javascript
- How to display image with JavaScript?
- Resize image with javascript canvas (smoothly)
- JavaScript function onhover in
- Check if an element contains a class in JavaScript?
- Hide element by class in pure Javascript
- How to play a mp3 using Javascript? [duplicate]
- mailto using javascript
- Function not defined javascript
- How to submit a form with JavaScript by clicking a link?
- How to call a REST web service API from JavaScript?
- Check a radio button with javascript
- AppendChild() is not a function javascript
- How can I change an element’s class with JavaScript?
- JavaScript: Get image dimensions
- Why write script type=”text/javascript” when the mime type is set by the server?
- How to select an input element by value using javascript?
- javascript window.location in new tab
- How to create a hidden in JavaScript?
- How do I programmatically set the value of a select box element using JavaScript?
- How can I capture the right-click event in JavaScript?
- How do I clear the content of a div using JavaScript?
- HTML encoding issues – “” character showing up instead of ” “
- Center image using text-align center?
- CSS Background Opacity [duplicate]
- How to create an HTML button that acts like a link
- Cannot set property InnerHTML of null [duplicate]
- How to get a tab character?
- Is there an upside down caret character?
- How to center text with Markdown?
- Disable Scrolling on Body
- Darken CSS background image?
- Vertical Text Direction
- TypeError: Cannot Set property ‘onclick’ of null
- How to darken a CSS background image?
- How can I create a marquee effect?
- What is “X-Content-Type-Options=nosniff”?
- Why is this HTML5 document invalid?
- Coin toss with JavaScript and HTML
- How do you give iframe 100% height
- HTML Display Current date
- How to display a gif fullscreen for a webpage background?
- Padding a table row
- document.getElementById().value doesn’t set the value
- How to run a function when the page is loaded?
- Clearing my form inputs after submission
- jquery – how to show a hidden div
- anchor jumping by using javascript
- How to create spoiler text?
- jQuery scrollTop() method not working
- FormData append not working
- How do I horizontally center a table in Bootstrap
- How do I center text in a span?
- text-align justify not working
- How to embed a Google Drive folder in a website
- Pure HTML Back Button
- How to access and download a file from a server using HTML 5
- Display text on MouseOver for image in html
- Layout a flex box similar to a table?
- html : iframe not showing content in html
- How can I publish Word files to a WordPress blog without losing the footnotes?
- Javascript code inside “” in core WordPress files .php
- Remove html markup by wordpress
- How can I set different html lang attribute for different countries?
- How to integrate my HTML and javascript into my child theme
- parts of url disappear when using # inside href=”” [closed]
- Can’t save any WordPress post with the html tag in it
- Noscript not working as it should in wordpress site
- remove string: ‘custom content…’ from every page
- Whitespace Before Doctype
- html entities occur in the_excerpt used as meta description
- Use Mail-Tag from Contac Form 7 in a script
- how to let users upload their custom cover image
- Possible jquery / library conflict in plugin usage
- How can I insert a disclaimer in a WordPress site?
- dropdown does not work [closed]