在慢速jQuery中设置功能显示/隐藏按钮
Set Function show/hide button in slow speed jQuery
请将此功能设置为慢速显示/隐藏按钮:
<button id="trmtn" onclick="trclick(this);"><span id="nod_trmtn">[+]</span>File</button>
文件隐藏:
<div id="bd_trmtn" style="display: none">
HELLO!
</div>
此功能:
var d = document;
function trclick(a){
var view,valbt;
var c=d.getElementById('bd_'+a.id);
var e=d.getElementById('nod_'+a.id);
view=c.style.display;c.style.display=(view==''?'none':'');
valbt=(view==''?'[+]':'[-]');
e.innerHTML=valbt;
}
使用jQuery可以很容易地做到这一点http://jsfiddle.net/f92vczpm/
HTML:
<button id="trmtn"><span id="nod_trmtn">[+]</span>File</button>
<div id="bd_trmtn" style="display:none;">
HELLO!
</div>
Javascript:
$(function(){
$('#trmtn').click(function(){
// get the ID of the button that was clicked
var thisID = $(this).attr('id');
// determine if your button will have a plus or minus after the toggle
spanText = $('#bd_' + thisID).is(':visible') ? "[+]": "[-]";
// get a reference to the span tag so you can update it in the callback function
span = $(this).find('span');
// toggle the div with speed of "slow" for slow motion. then use callback function to change the button text
$('#bd_' + thisID).slideToggle("slow", function(){ $(span).text(spanText); });
})
});
为此,您必须包含一个版本的jQuery。
$('selector').hide(speed,callback);
$('selector').show(speed,callback);
例如动画其消失(缓慢)
$('element').hide(1000);
或
$("element").hide('slow');
使用jQuery
,您可以按照以下方式进行操作。CCD_ 2显示并且CCD_ 3在给定时间内隐藏该元素。希望这对你有帮助。
$('#trmtn').click(function(){
var bd = $('#bd_trmtn');
if(!bd.is(':visible')){
bd.fadeIn(2000); //take 2s to show
$(this).find('#nod_trmtn').html('[-]');
}else{
bd.fadeOut(2000); //take 2s to hide
$(this).find('#nod_trmtn').html('[+]');
}
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="trmtn"><span id="nod_trmtn">[+]</span>File</button>
<div id="bd_trmtn" style="display: none">
HELLO!
</div>
相关文章:
- 在jquery中为显示/隐藏设置cookie
- PHP Javascript显示/隐藏按钮不工作
- 打开/关闭按钮以显示/隐藏内容
- 显示隐藏复选框
- 在bootstrap中显示隐藏特定的li
- JQuery上下文菜单显示/隐藏问题
- JQuery在单击时停止显示/隐藏
- HTML5在提交并显示所需标签后显示隐藏的表单元素
- 使用 jQuery 切换显示/隐藏
- 显示/隐藏有关模型更改的指令内容
- Bootstrap在页面加载缓慢时会立即显示隐藏的模式对话框
- 根据特定条件使用ng显示/ng隐藏来显示/隐藏元素
- 显示/隐藏不起作用
- 使用ng-hide根据条件显示/隐藏按钮
- 仅在第一个结果中显示/隐藏MySQL结果函数
- 显示/隐藏http://ftp链接
- 在显示/隐藏中单击时删除的文本
- 是否可以在不重新渲染的情况下显示/隐藏父对象中的元素
- 将页面内容向左移动时显示/隐藏右侧面板
- 显示/隐藏将不会加载