Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement the jQuery add and delete button Click event

Shulou Source: shulou.com Published: 2022-06-01 02:43:51 09月22日 Update

This article mainly introduces "how to achieve jQuery add and delete button Click event". In daily operation, I believe many people have doubts about how to achieve jQuery add and delete button Click event. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubt of "how to achieve jQuery add and delete button Click event". Next, please follow the editor to study!

As shown in the following figure, check "I have read and accept." Check box, the Login button will respond to the click event, after a successful login to switch to the welcome screen.

Usually how do we implement it? many students will think of using javascript to set the disabled property of the button. Of course, this is a good method, but if we use JQuery, the code will be more concise, and our forced grid will also go up, .

For buttons, JQuery provides the bind () method and the unbind () method, which allow us to add or remove Click events to the button anytime, anywhere, as needed.

The detailed code is as follows:

.hide {display: none;} .show {display: block;} $(document) .ready (function () {$('# logoutBtn'). AddClass ('hide'); $(' # logoutBtn'). Bind ('click', function () {$(' # title'). Html ('Agreements)

1....

2....

3.); $('# loginBtn'). RemoveClass ('hide'). AddClass (' show'); $('# confirm'). RemoveClass ('hide'). AddClass (' show'); $('# logoutBtn'). RemoveClass ('show'). AddClass (' hide');}) Function doCheck () {if ($("input [type = 'checkbox']"). Is (': checked')) {$('# loginBtn'). Bind ('click', function () {$(' # title'). Text ('Welcome to our sitepieces'); $('# loginBtn'). RemoveClass ('show'). AddClass (' hide'); $('# confirm'). RemoveClass ('show'). AddClass (' hide') $('# logoutBtn'). RemoveClass ('hide'). AddClass (' show');});} else {$('# loginBtn'). Unbind ('click');}} Agreements

1....

2....

3....

Tags: Buttons methods events elements learning selection code content more styles check boxes help good practical concise successful and then anytime anywhere classmate reunion Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Huawei Xiaomi Docker