Home > Backend Development > PHP Tutorial > 通过jquery加载的元素,要怎样才能进行控制?

通过jquery加载的元素,要怎样才能进行控制?

WBOY
Release: 2016-06-06 20:26:03
Original
1270 people have browsed it

原html

<code>
</code>
Copy after login
Copy after login

a.php

<code><?php echo "<input id=\"cancel\" type=\"button\" value=\"取消\">";</code>
Copy after login
Copy after login

jquery

<code>$(document).ready(function(){
    $(".button").bind({
        click:function(){
            $.get("./create.php",function(data){
                $("body").append(data)
            })
        }
    })
    
    $("input").click(function(){
        alert(123456);
    })
})</code>
Copy after login
Copy after login

新html

<code>
    <div>
        <input id="cancel" type="button" value="取消">
    </div>
</code>
Copy after login
Copy after login

回复内容:

原html

<code>
</code>
Copy after login
Copy after login

a.php

<code><?php echo "<input id=\"cancel\" type=\"button\" value=\"取消\">";</code>
Copy after login
Copy after login

jquery

<code>$(document).ready(function(){
    $(".button").bind({
        click:function(){
            $.get("./create.php",function(data){
                $("body").append(data)
            })
        }
    })
    
    $("input").click(function(){
        alert(123456);
    })
})</code>
Copy after login
Copy after login

新html

<code>
    <div>
        <input id="cancel" type="button" value="取消">
    </div>
</code>
Copy after login
Copy after login

题主的问题本质地是如何控制动态插入的新节点。用 jQuery 的话,可以这么来:

<code>$(document).on('click', 'input', function() {
    alert(123456);
});</code>
Copy after login
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