afridy
January 29, 2010, 7:20pm
1
folks,
<script language="JavaScript">
$(document).ready(function(){
$('p#optbox').hide();
$('a#showhide').click(function(){
$('p#optbox').slideDown('slow');
});
});
</script>
when i click a#showhide link, the ‘p#optbox’ is shown.
now my problem is, when i click again ‘p#optbox’ should hide.
how to check the show hide status of an eliment using jquery?
i did not find a good jquery conditional statement thing when google . so pls help.
I’d suggest using toggle , or you could try this:
<script language="JavaScript">
$(document).ready(function(){
$('p#optbox').hide(); // Should use CSS for this
$('a#showhide').click(
function(){
if($('p#optbox').is(':visible')){
$('p#optbox').slideUp('slow');
}
else{
$('p#optbox').slideDown('slow');
}
}
);
});
</script>
afridy
January 30, 2010, 4:55am
3
awestmoreland:
I’d suggest using toggle , or you could try this:
<script language="JavaScript">
$(document).ready(function(){
$('p#optbox').hide(); // Should use CSS for this
$('a#showhide').click(
function(){
if($('p#optbox').is(':visible')){
$('p#optbox').slideUp('slow');
}
else{
$('p#optbox').slideDown('slow');
}
}
);
});
</script>
Fantastic ! the toggle worked for me simply
Thank you awestmoreland