javascript - Onclick attribute with if statement -


click1=document.getelementbyid("job1"); click2=document.getelementbyid("job2"); if (click1.onclick) {     x=1;     store(x); } else {     x=2;     store(x); } 

why won't work , instead loads next function without clicking?

you can try instead:

click1=document.getelementbyid("job1"); click2=document.getelementbyid("job2"); click1.onclick= function() {     x=1;     store(x); } click2.onclick = function() {     x=2;     store(x); } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -