开发者

Restrict the 'slideToggle' animation at once when click the radiobutton?

Is it possible to restrict the action of slideToggle animation at once when someone click the radiobutton..? I have a yes or no question and I wrote a simple JQuery f开发者_StackOverflowor showing a hidden div when I click 'yes' radiobutton, the problem is its repeating the hide/show action when I click the 'yes' button..

any solutions for this...?

Although I'm new in JQuery though my JQuery code is given below

$(document).ready(function(){
    $('#d01').click(function(){
            $(".c01").slideToggle();    
    });

    $('#d02').click(function(){
             $(".c01").hide();
    });
)};

(#d01) - stands for 'yes' radio button.

(#d02) - stands for 'no' radio button.

(.c01) - stands for hidden div.

Akhil


Change slideToggle to slideDown. slideToggle will hide the element if it's already shown, and show it if it's hidden. That is to say, it "toggles" between hidden and shown, hence the name.

slideDown on the other hand will display the matched elements if they are hidden, and do nothing otherwise.

Note that you could also use show, and you could also use slideUp in place of hide in your #d02 click event handler if you want the animation to take effect there as well.


Try this

$(document).ready(function(){
    $('#d01').click(function(){
            $(".c01").slideDown();    
    });

    $('#d02').click(function(){
             $(".c01").slideUp();
    });
)};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜