mardi 1 décembre 2015

How to refresh variable value to run different part of code

The code runs after a button is hit, I have two problems.

  1. The code runs only after second hit
  2. It doesn't change the value and if statement, it always repeats the false part.

The first time then vote is not given it is ok, it is the show else part, but then I vote its still giving false part. What am I doing wrong?

function checking(){

    var check = document.getElementById('vote_respond').innerHTML;

    if (check =='Ačiū kad balsavote' || check=='Jus jau atidavete savo balsa') {
        $( "#vote_respond" ).text( "already voted" ); //inserting text into element with id="vote_respond"
    } else {
        $( "#vote_respond" ).text( "you can vote" );
    };

Aucun commentaire:

Enregistrer un commentaire