I need some help with this accordion. Please see the demo here. http://jsfiddle.net/a36RL/
$(document).ready(function() {
$('div.accordionButton').click(function() {
$('div.accordionContent').slideUp('slow');
$(this).next().slideDown('slow');
});
$("div.accordionContent").hide();
});
I need to make a little开发者_开发问答 changes in it.
- I want the first tab down by default.
- If a tab is already down, and that tab is clicked again, there should not be anything (Currently it slides up and then down again).
Thanks for the help.
You can trigger the click event on the first button to open the first tab. Try this:
$(document).ready(function() {
$('div.accordionButton').click(function() {
if($(this).next().is(":visible")){
return;
}
$('div.accordionContent').slideUp('slow');
$(this).next().slideDown('slow');
});
$("div.accordionContent").hide();
$("div.accordionButton:eq(0)").click();
});
Working example @:
http://jsfiddle.net/a36RL/7/
精彩评论