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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:26:031299browse

原html

<code>
</code>

a.php

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

jquery

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

新html

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

回复内容:

原html

<code>
</code>

a.php

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

jquery

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

新html

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

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

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