一次只允许显示一个切换div [英] Allow only one toggle div to show at a time
本文介绍了一次只允许显示一个切换div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HTML代码: -
HTML Code :-
<div class="toggler">
<div id="effect" class="ui-widget-content ui-corner-all" style="display:none">
<h3 class="ui-widget-header ui-corner-all">Toggle 1</h3>
</div>
<div id="effect1" class="ui-widget-content ui-corner-all" style="display:none">
<h3 class="ui-widget-header ui-corner-all">Toggle 2</h3>
</div>
</div>
<a href="#" id="button" class="ui-state-default ui-corner-all">Run Effect 1</a>
<a href"#" id="btn" class="ui-state-default ui-corner-all">Run Effect 1 </a>
jquery代码: -
jquery code :-
<script>
$(function()
{
// run the currently selected effect
function runEffect()
{
// get effect type from
var selectedEffect = 'fold';
// most effect types need no options passed by default
var options = {};
// run the effect
$( "#effect" ).toggle( selectedEffect, options, 500 );
};
// set effect from select menu value
$( "#btn" ).dblclick(function()
{
runEffect();
return false;
});
function runEffect1()
{
// get effect type from
var selectedEffect1 = 'drop';
// most effect types need no options passed by default
var options1 = {};
// run the effect
$( "#effect1" ).toggle( selectedEffect1, options1, 500 );
};
// set effect from select menu value
$( "#button" ).click(function()
{
runEffect1();
return false;
});
});
</script>
如何一次只显示一个切换请帮帮我
how to show only one toggle at a time please help me
推荐答案
(function()
{
// 运行当前选定的效果
函数runEffect()
{
// 从获取效果类型
var selectedEffect = ' fold';
// 效果最佳类型不需要默认传递的选项
var options = {};
// 运行效果
(function() { // run the currently selected effect function runEffect() { // get effect type from var selectedEffect = 'fold'; // most effect types need no options passed by default var options = {}; // run the effect
( #effect)。togoggle(selectedEffect,options, 500 ) ;
};
// 从选择菜单值设置效果
( "#effect" ).toggle( selectedEffect, options, 500 ); }; // set effect from select menu value
( #btn)。dblclick(function()
{
runEffect();
return false ;
});
函数runEffect1()
{
// 从获取效果类型
var selectedEffect1 = ' < span class =code-string> drop';
// 大多数效果类型不需要默认传递选项
var options1 = {};
// 运行效果
( "#btn" ).dblclick(function() { runEffect(); return false; }); function runEffect1() { // get effect type from var selectedEffect1 = 'drop'; // most effect types need no options passed by default var options1 = {}; // run the effect
这篇关于一次只允许显示一个切换div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文