0

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.

method:

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!

2
  • 1
    Have you tried anything, where exactly are you stuck? SO is not a code writing service. Commented Jun 27, 2013 at 5:55
  • 1
    This can easily be accomplished by doing a Google search. Please try yourself, this way you can learn more. Commented Jun 27, 2013 at 5:57

3 Answers 3

1

Try

$("#shown, #hidden").slideToggle("slow"); 

DEMO

Sign up to request clarification or add additional context in comments.

Comments

1

try this:

DEMO --> http://jsfiddle.net/YFmtc/2/

$("#hidden").hide();
$('a').click(function(){
        $("#shown, #hidden").slideToggle("slow");
});

See API slideToggle()

Comments

0

Try

function show(shown, hidden) {
  $('#' + shown).show();
  $('#' + hidden).hide();
  return false;
}

or

function show(shown, hidden) {
  $('#' + shown + ',' + '#' + hidden).toggle();
  return false;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.