Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 16:48:121251browse

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') ;});
Statement:
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