jquery - Assign 2 actions to one html button -
im trying assign 2 actions 1 button in webpage:
- send message arduino run server
- change color of button toggleclass can see if it's on/off
code:
function autoon() { $('#content').load('/arduino/autoon'); $("button#autoon").click(function () { $(this).toggleclass("selected"); }); } now color of buttons change need click button 2 times change color.
why don't change button's class inside autoon function?
$("#autoon").toggleclass("selected"); so autoon function become:
function autoon() { $('#content').load('/arduino/autoon'); $("#autoon").toggleclass("selected"); }
Comments
Post a Comment