joy
joy

Reputation: 81

Show/hide script cannot hide again on 2nd click

I used jquery show/hide in many place in my web. every where its work well but in this case its not hide again in 2nd click.

here is the example: http://jsfiddle.net/er9e72ww/

show/hide code

$('#uploadMedia').livequery("click",function(){
  $('#show_img_upload_div').slideToggle('slow');
  $("#comment").focus();
  $('.upfrm').show();
  $('#submit').hide();
});

Upvotes: 0

Views: 69

Answers (3)

Salil Dabholkar
Salil Dabholkar

Reputation: 622

Just use .slideToggle('slow'); instead of show() and hide() like:

$('#uploadMedia').livequery("click", function () {
    $('#show_img_upload_div').slideToggle('slow');
    $("#comment").focus();
    $('.upfrm').slideToggle('slow');
    $('#submit').slideToggle('slow');
});

Upvotes: 0

Suchit kumar
Suchit kumar

Reputation: 11859

the problem here is you are hiding/showing submit/upfrm but not showing/hide it again.use toggle for this:

$('.upfrm').toggle();
$('#submit').toggle();

Upvotes: 0

Balachandran
Balachandran

Reputation: 9637

use toggle() in jquery to hide and show repeatedly

$('#uploadMedia').livequery("click",function(){
$('#show_img_upload_div').slideToggle('slow');
$("#comment").focus();
$('.upfrm').toggle();
$('#submit').toggle();
});

DEMO

Upvotes: 2

Related Questions