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

java - Incorrect order of records in M-M relationship in hibernate -

command line - Use qwinsta in PowerShell ISE -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -