Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Thumbs up/down
    primarykey
    data
    text
    <p>I have the following javascript, which is linked to a thumbs up and thumbs down button. When each is click the other turns off. This works perfectly. However the localstorage part doesn't</p> <p>At the moment, when i refresh the page both buttons come 'on' (their active state colour) I was trying to use removeItem so that when a button is pressed the localstorage for the other is forgotten and it won't show. However they both still come one.</p> <p>Any ideas</p> <p><strong>Updated;</strong> Changed to ThumbStatus</p> <pre><code>function thumbsup(){ document.getElementById("thumbsup").classList.remove("btn-default") document.getElementById("thumbsup").classList.add("btn-success") document.getElementById("thumbsdown").classList.remove("btn-danger") document.getElementById("thumbsdown").classList.add("btn-default") localStorage.setItem('ThumbStatus',up); localStorage.removeItem('ThumbStatus', down); } function thumbsdown(){ document.getElementById("thumbsdown").classList.remove("btn-default") document.getElementById("thumbsdown").classList.add("btn-danger") document.getElementById("thumbsup").classList.remove("btn-success") document.getElementById("thumbsup").classList.add("btn-default") localStorage.setItem('ThumbStatus',down); localStorage.removeItem('ThumbStatus', up); } function Loadthumbs1() { //if something was already saved.... if ( localStorage.getItem('ThumbStatus', up) ) { var up = localStorage.getItem('ThumbStatus', up); } document.getElementById("thumbsup").classList.add("btn-success") } function Loadthumbs2() { if ( localStorage.getItem('ThumbStatus', down) ) { var down = localStorage.getItem('ThumbStatus', down); } document.getElementById("thumbsdown").classList.add("btn-danger") } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload