Javascript 如何禁用除div之外的全身
Javascript 如何禁用除div之外的全身,javascript,jquery,html,Javascript,Jquery,Html,我有一个通过ajax创建的div,我想在该div弹出后禁用整个主体,直到,除非该div关闭。在jquery中可以这样做吗。请告诉我你的建议 谢谢,Praveen Jayapal你想移除还是隐藏尸体?从技术上讲,这是不可能的,因为您需要将div附加到主体中才能看到它。你可以做的是创建一个覆盖整个身体的“遮罩”层,然后对你的div使用z-index将其显示在身体顶部 比如: 也许会有帮助 要完全隐藏页面,只需更改第21行: $(“#mask”).fadeTo(“慢”,0.8) 在javascrip
我有一个通过ajax创建的div,我想在该div弹出后禁用整个主体,直到,除非该div关闭。
在jquery中可以这样做吗。请告诉我你的建议
谢谢,
Praveen Jayapal你想移除还是隐藏尸体?从技术上讲,这是不可能的,因为您需要将div附加到主体中才能看到它。你可以做的是创建一个覆盖整个身体的“遮罩”层,然后对你的div使用z-index将其显示在身体顶部 比如: 也许会有帮助 要完全隐藏页面,只需更改第21行:
$(“#mask”).fadeTo(“慢”,0.8)代码>
在javascript中:
$(“#mask”).fadeTo(“slow”,1)代码>
CSS第7行的遮罩颜色也可以更改为您想要的任何颜色:
背景色:#000代码>应该可以做到这一点
HTML:
Javascript:
<script type="text/javascript">
$(document).ready(function() {
//your ajax-call
$.ajax({
//on success
success: function() {
//your logic your showing the ajax-div
$('#overlay').show(); //or fadeIn()
}
})
//use live to catch the close-click of the later added ajax-div
$('#ajax-div a#close').live('click', function() {
//close the ajax-div
$(this).parent().hide();
//close the overlay
$('#overlay').hide(); //or, again, fadeOut()
});
});
</script>
$(文档).ready(函数(){
//您的ajax调用
$.ajax({
//论成功
成功:函数(){
//您的逻辑是显示ajax div
$('#overlay').show();//或fadeIn()
}
})
//使用live捕捉稍后添加的ajaxdiv的关闭点击
$('#ajax div a#close').live('click',function(){
//关闭ajax div
$(this.parent().hide();
//关闭覆盖层
$('#overlay').hide();//或者,再一次,fadeOut()
});
});
听起来你想要的是一个模式对话框
有许多JQuery脚本可以很容易地实现这一点。以下是您的一些链接:
希望有帮助。好的。。。如果使用jquery,最好使用jquey.ui
您可以选择主题并仅下载您喜欢的组件
然后,只需将js和css包含在PlaceIMG文件夹和call对话框中。这很容易…A在那里努力,蒂姆!很好,听起来像个灯箱。查阅
#overlay {
background-color: #ccc; /*or semitransparent image*/
display: none;
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 100;
}
#ajax-div {
z-index: 200; /*important, that it is above the overlay*/
}
<script type="text/javascript">
$(document).ready(function() {
//your ajax-call
$.ajax({
//on success
success: function() {
//your logic your showing the ajax-div
$('#overlay').show(); //or fadeIn()
}
})
//use live to catch the close-click of the later added ajax-div
$('#ajax-div a#close').live('click', function() {
//close the ajax-div
$(this).parent().hide();
//close the overlay
$('#overlay').hide(); //or, again, fadeOut()
});
});
</script>