I want to make a script that changes the text of the switching link depending on the visibility of the element.
So, while #form apparently, I want the # form-container text to be "Hide ...", and while it is hidden, I want the text to be "Show ...".
I tried this line - if ($ ('# form'). Is (": visible")) {another way: if ($ ('# form'). Is (": visible") = = "true") {- but it also doesn't work.
What happened? How to change text each time another item is switched?
$('.toggle').click(
function()
{
$('#form').slideToggle();
if($('#form').is(":visible")){
$('#form-container a').text("Hide form container");
}
else {
$('#form-container a').text("Show form container");
}
});
Thank.
source
share