javascript - Toggle button isn`t working?(Uncaught SyntaxError: Unexpected identifier ) -
there problem code. use button hide , show menu isn't working. didn't understand problem.
uncaught syntaxerror: unexpected identifier :: par. 3
$(function() { $(".but").click( { if $("#div").hasclass("class"){ //problem here $("#div").removeclass("class").addclass("anotherclass"); } else{ $("#div").removeclass("anotherclass"").addclass("class"); } }); });'
as others have said you're missing function, "but" not valid selector, , added () in if statement, that's coding preference
$(function () { $("button").click(function () { //but not valid selector, button if ($("#div").hasclass("class")) { //problem here $("#div").removeclass("class").addclass("anotherclass"); } else { $("#div").removeclass("anotherclass").addclass("class"); } }); });
Comments
Post a Comment