Ajax和Jquery keyup不起作用[duplicate]

时间:2022-12-06 19:26:15

This question already has an answer here:

这个问题已经有了答案:

In main.php i call settings.php with ajax, inside settings there is one input text field with id #newlogintext, if i put the jquery keyup in settings.php it's working, but if i put it in main.php it's not working.

在主。php设置。使用ajax的php,在设置中有一个id为#newlogintext的输入文本字段,如果我将jquery键放在设置中。php可以运行,但是如果我把它放到main中。php不工作。

in main php i call settings.php :

在主php中,我调用settings。php:

function CheckSettings() {

$.ajax({
   type: 'POST',
   url: 'settings.php',
   data: form_data,
   success: function(data) 
   {
      $("#settings").html(data); 
   }
});
}
CheckSettings();

Keyup:

Keyup:

$( document ).ready(function() {
$("#newlogintext").on("keyup", function(){
alert("test");
});
});

Settings php:

设置php:

<div class="settings">
<b> General Settings </b>
<br>
<p>New login:</p> <input id="newlogintext" type="text" name="newlogin" />
</div>

1 个解决方案

#1


2  

Please try this :
$(document.body).on("keyup","#newlogintext",function(){
alert("test");
});

#1


2  

Please try this :
$(document.body).on("keyup","#newlogintext",function(){
alert("test");
});