jQuery的禁用页面的一部分 [英] jquery disable parts of page

查看:93
本文介绍了jQuery的禁用页面的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在页面顶部显示无模式的jquery对话框.当显示对话框时,我只希望用户与页面的特定部分进行交互(主要是因为我不希望他们闲逛或单击其他引起回发的控件).我认为将jquery与模式对话框一起使用的相同机制会很好用,除了禁用整个页面之外,禁用所有我希望保持活动的部分,而不是禁用整个页面.有人知道jquery模态对话框如何做到这一点或有更好的建议吗?

I am displaying a modeless jquery dialog on top of a page. When the dialog is displayed I wish to only allow the user to interact with a certain portion of the page (mainly because I do not want them naving away or clicking other controls that cause postbacks). I thought it would work well to use the same mechanism that jquery uses with a modal dialog except instead of disabling the entire page, disable all but the portion I wish to remain active. Does someone know how jquery modal dialog does this or have a better suggestion?

推荐答案

如果只想阻止发布/导航,请使用window.unload捕获并阻止该事件.

If you only want to prevent posting/navigation, then use window.unload to capture and prevent the event.

如果您需要有选择地禁用输入控件,则将disabled属性应用于这些控件.

If you need to selectively disable input controls, then apply the disabled property to those controls.

您可以通过为要在给定情况下禁用或启用的每个对象分配一个类来轻松实现此目的,例如用jQuery

You can do this easily by assigning a class to every object that you want to disable or enable for a given circumstance, e.g. with jquery

$('.blocked-input-controls').prop('disabled',true);

这篇关于jQuery的禁用页面的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆