Home > Web Front-end > JS Tutorial > Solve the problem of executing multiple functions when the html button is switched and bound to different functions and then clicked_javascript skills

Solve the problem of executing multiple functions when the html button is switched and bound to different functions and then clicked_javascript skills

WBOY
Release: 2016-05-16 16:48:12
Original
1291 people have browsed it

Both deleting posts and locking posts require filling in the reason for rejection. They share a window and a button. The buttons are bound to different events:

title = 'Delete post (blocked, not displayed)';

Copy code The code is as follows:

$('#btn_ok', '#div_deny_reason').bind('click' , function(){edit('if_show', '0');});
title = 'Lock post';
$('#btn_ok', '#div_deny_reason').bind('click' , function(){edit('if_lock', '1');});

As a result, after locking the post and then deleting the post, edit() will be executed twice. Just change

to the following:
Copy the code The code is as follows:

title = 'Delete post (block, don't show)';
$('#btn_ok', '#div_deny_reason').one('click', function(){edit('if_show', '0') ;});
title = 'Lock post';
$('#btn_ok', '#div_deny_reason').one('click', function(){edit('if_lock', '1') ;});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template