[英]JQuery slideToggle display type
我正在使用jQuery slideToggle来显示隐藏的表格行,但它将显示样式设置为阻止,我需要显示表格行。 任何想法我怎么能做到这一点?
提前致谢
我找到了解决这个问题的方法 - 检查显示是否已设置为阻止(如果元素已被切换显示),如果设置为所需的显示类型。
$('a.btn').on('click', function() {
$('div.myDiv').slideToggle(200, function() {
if ($(this).css('display') == 'block') $(this).css('display', 'table-row'); // enter desired display type
});
});
inorganik的解决方案几乎正常。 但是您还需要设置step
回调以将block
更改为table-row
。
$('row-selector-here').slideToggle({
duration: 'fast',
step: function() {
if ($(this).css('display') == 'block') {
$(this).css('display', 'table-row');
}
},
complete: function() {
if ($(this).css('display') == 'block') {
$(this).css('display', 'table-row');
}
}
});
您可以使用回调来更改此设置
$('#tableRowId').slideToggle( function(){
$(this).css('display', 'table-row');
});
只需将此代码添加到回调函数即可
$(this).css('display','');
只需将其默认为css即可
.block { display: table }
然后在加载页面时,您可以将其向上滑动
$(document).ready(function () {
$('.btn').click(function(){
$('.block').slideToggle();
})
$('.block').slideUp();
});
下次它向下滑动它将显示:table。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.