Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How jquery forbids clicking on elements

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how jquery prohibits clicking elements". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "how jquery prohibits clicking elements" together!

jquery Forbidden click element implementation method: 1, by "$(this).click(function (event) {...} "way;2. by"$('a ').live ('click', function(event) {...} "Manner, etc.

Operating environment: Windows 7 system, jquery3.2.1 version, DELL G3 computer

How does jquery prohibit clicking elements?

Click events to remove or disable html elements can be implemented through CSS or js or jQuery.

1. CSS method

.disabled { pointer-events: none; }

2. jQuery method

method one

$(this).click(function (event) {event.preventDefault();}

methodology II

$('a').live('click', function(event) { alert("Sorry, this is disabled! "); event.preventDefault();});

Note: Live in this method can also be on, bind, etc.

method three

$('. disableCss').removeAttr ('onclick ');//remove onclick event from tag

Control the html tag's properties by removeAttr method has reached enable or disable event. In addition, other events or effects can be controlled in this way.

method four

$('#button').attr ('disabled ',"true");//add disabled attribute $('#button').removeAttr ('disabled'); //remove disabled attribute

Note: Same as method 3, except disabled attribute is generally used on input of type button or submit

Thank you for reading, the above is "jquery how to prohibit clicking elements" content, after the study of this article, I believe we have a deeper understanding of how jquery prohibits clicking elements, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report