javascript - Change text when link clicked with jQuery -


i'd change button read close when clicked , act close too.

fiddle demo

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');         }     }); }); 

demo


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -