javascript - Trying to switch 0 for 1 in the end of the function but it doesnt work -
i having problem witht code.
in end of function trying switch 1 0 or 0 1;
this button should after each click change words hello or stop clicking me;
big in advance
function mediadropdown() { var hello="hello"; var stopclicking="stop clicking me"; var notclicked=1; if(notclicked < 1) { document.getelementbyid("mediaarea").innerhtml=hello; } if(notclicked > 0) { document.getelementbyid("mediaarea").innerhtml=stopclicking; } changepolarity(); } function changepolarity() { if(notclicked<1) { notclicked=1; } if(notclicked>0) { notclicked=0; } }
the notclicked
variable non-persistent; every time run mediadropdown function being redefined , set 1 see text "stop clicking".
move outside of function retains value.
var notclicked=1; function mediadropdown() { var hello="hello"; var stopclicking="stop clicking me";
Comments
Post a Comment