Summary of common methods for jQuery to remove or disable html element click events, and jquery to remove
This document describes how to use jQuery to remove or disable html element click events. We will share this with you for your reference. The details are as follows:
The click event for removing or disabling html elements can be implemented through css or js or jQuery.
I. CSS Method
. Disabled {pointer-events: none ;}
Ii. jQuery Method
Method 1
$(this).click(function (event) {event.preventDefault();}
Method 2
$ ('A'). live ('click', function (event) {alert ("sorry, disabled! "); Event. preventDefault ();});
Note: live in this method can also be thought of as on, bind, and other methods.
Method 3
$ ('. DisableCss'). removeAttr ('onclick'); // remove the onclick event from the tag.
The removeAttr method is used to control the attribute of html tags to enable or disable events. In addition, you can use this method to control other events or other effects.
Method 4
$ ('# Click '). attr ('Disabled ', "true"); // Add the disabled attribute $ (' # click '). removeAttr ("disabled"); // remove the disabled attribute
Note: This is the same as method 3. However, the disabled attribute is generally used in the input of the button or submit type.
PS: the online comparison table of common javascript events and function descriptions is provided here for your reference:
Javascript events and functions:
Http://tools.jb51.net/table/javascript_event