Why the message is not displayed when you click on the button #knopka_OK ?

 function form_input() { html = ''; html += '<button id="knopka_OK">Запись хода</button>'; $(html).appendTo('#body') $('#knopka_OK').hide() $('#qwe').click(function () { form_input(); }) $('#qwe').click(function () { $(this).unbind('click'); }) $('#knopka_OK').click(function () { alert('fgtrhfyh'); }) } 
  • Put the code on jsfiddle.net pliz - we will help, and so ... - thunder
  • @MikeVin; To format a code, select it with the mouse and click on the {} button of the editor. - Nicolas Chabanovsky
  • but where is that? where is form_input() called? it does not start anywhere, accordingly no handlers will be hung on the button ... - thunder
  • Let's start by shortening your code. function form_input () {$ ('<button id = "knopka_OK"> Track Record </ button>'). appendTo ('# body') $ ('# knopka_OK'). hide (). click (function () { alert ('fgtrhfyh');})} Now, explain where and how you press a button or imitate a click on it and what is wrong? - Crasher

1 answer 1

The message is not displayed because you only add a description of the action to the click event. To simulate a click action try


In general, if I understood your task correctly, it is better to do this: http://jsfiddle.net/5WBmX/