Swapping out a class for another in jQuery -
i'm having difficulty changing class of button element using jquery. currently, adds class button element.
this code far. how can resolve it?
$(function () { $("#admin").click(function () { $('#normal').show(); $('#admin').hide(); $('.delete_admin').toggleclass("delete_normal"); return false; }); $("#normal").click(function () { $('#normal').hide(); $('#admin').show(); $('.delete_normal').toggleclass("delete_admin"); }); });
if elements starts out 1 class, toggle both classes, removing existing one, , adding new one, so:
$(function () { $("#admin").click(function () { $('#normal').show(); $('#admin').hide(); $('.delete_admin').toggleclass("delete_normal delete_admin"); return false; }); $("#normal").click(function () { $('#normal').hide(); $('#admin').show(); $('.delete_normal').toggleclass("delete_normal delete_admin"); }); });
Comments
Post a Comment