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 to implement the jQuery add and delete button Click event

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

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....

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