javascript - Change text when link clicked with jQuery -
i'd change button read close
when clicked , act close too.
how achieve current code?
jquery:
$(document).ready(function() { // expand panel $("#open").click(function(){ $("div#panel").slidedown("slow"); }); // switch visiblility of "close panel" button $("#close").click(function () { $("div#panel").slideup("slow"); }); });
you can use .is(':visible')
check whether div visible , set text appropriately.
code
$("#open").click(function () { $("div#panel").slidetoggle("slow", function () { if ($("div#panel").is(':visible')) { $("#open").text('close'); } else { $("#open").text('quick quote'); } }); });
Comments
Post a Comment