Reputation: 6815
I am new to jquery. I wrote one javascript method and will be called on click of an anchor.
onclick="return show('contentTwo','content');
here contentTwo
and content
are div Ids.
function show(shown, hidden) {
document.getElementById(shown).style.display='block';
document.getElementById(hidden).style.display='none';
return false;
}
Now I would like to use jquery's slideDown
and slideUp
methods than using javascript. how can I convert the above code into jquery?
Thanks!
Upvotes: 0
Views: 60
Reputation: 17366
try this:
DEMO -->
http://jsfiddle.net/YFmtc/2/
$("#hidden").hide();
$('a').click(function(){
$("#shown, #hidden").slideToggle("slow");
});
See API slideToggle()
Upvotes: 1
Reputation: 388326
Try
function show(shown, hidden) {
$('#' + shown).show();
$('#' + hidden).hide();
return false;
}
or
function show(shown, hidden) {
$('#' + shown + ',' + '#' + hidden).toggle();
return false;
}
Upvotes: 0