<bdo id='PX6cB'></bdo><ul id='PX6cB'></ul>

        <legend id='PX6cB'><style id='PX6cB'><dir id='PX6cB'><q id='PX6cB'></q></dir></style></legend>

        <small id='PX6cB'></small><noframes id='PX6cB'>

        <tfoot id='PX6cB'></tfoot>
      1. <i id='PX6cB'><tr id='PX6cB'><dt id='PX6cB'><q id='PX6cB'><span id='PX6cB'><b id='PX6cB'><form id='PX6cB'><ins id='PX6cB'></ins><ul id='PX6cB'></ul><sub id='PX6cB'></sub></form><legend id='PX6cB'></legend><bdo id='PX6cB'><pre id='PX6cB'><center id='PX6cB'></center></pre></bdo></b><th id='PX6cB'></th></span></q></dt></tr></i><div id='PX6cB'><tfoot id='PX6cB'></tfoot><dl id='PX6cB'><fieldset id='PX6cB'></fieldset></dl></div>

        jQuery 无法访问附加元素

        jQuery can#39;t access append element(jQuery 无法访问附加元素)

          <legend id='1gpDh'><style id='1gpDh'><dir id='1gpDh'><q id='1gpDh'></q></dir></style></legend>
        • <tfoot id='1gpDh'></tfoot>

              <bdo id='1gpDh'></bdo><ul id='1gpDh'></ul>
                <tbody id='1gpDh'></tbody>

              <small id='1gpDh'></small><noframes id='1gpDh'>

              <i id='1gpDh'><tr id='1gpDh'><dt id='1gpDh'><q id='1gpDh'><span id='1gpDh'><b id='1gpDh'><form id='1gpDh'><ins id='1gpDh'></ins><ul id='1gpDh'></ul><sub id='1gpDh'></sub></form><legend id='1gpDh'></legend><bdo id='1gpDh'><pre id='1gpDh'><center id='1gpDh'></center></pre></bdo></b><th id='1gpDh'></th></span></q></dt></tr></i><div id='1gpDh'><tfoot id='1gpDh'></tfoot><dl id='1gpDh'><fieldset id='1gpDh'></fieldset></dl></div>

                  本文介绍了jQuery 无法访问附加元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在一个函数中有这个:

                  I have this inside a function:

                  $('#users').append($("<div id='usuarios'>").text(mensaje[1][i]));
                  

                  我想为这个新的 <div> 创建一个 onclick 事件.我怎样才能做到这一点?我在函数外这样尝试:

                  I want to create an onclick event for this new <div>. How can I achieve this? I'm trying it like this outside the function:

                  $(document).ready(function(){
                  $('#usuarios').click(function() {
                          alert("click");
                      });
                  });
                  

                  但它不起作用.

                  推荐答案

                  对于 jQuery 1.7+,您可以使用 .on()

                  For jQuery 1.7+ you can attach an event handler to a parent element using .on()

                  $(document).ready(function(){
                    $('body').on('click', '#usuarios', function() {
                       alert("click");
                    });
                  });
                  

                  甚至更好:

                  $(document).ready(function(){
                    $('#users').on('click', '#usuarios', function() {
                       alert("click");
                    });
                  });
                  

                  这篇关于jQuery 无法访问附加元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)

                      <tbody id='Nt2Y3'></tbody>
                    <tfoot id='Nt2Y3'></tfoot>

                    <small id='Nt2Y3'></small><noframes id='Nt2Y3'>

                    <legend id='Nt2Y3'><style id='Nt2Y3'><dir id='Nt2Y3'><q id='Nt2Y3'></q></dir></style></legend>
                  1. <i id='Nt2Y3'><tr id='Nt2Y3'><dt id='Nt2Y3'><q id='Nt2Y3'><span id='Nt2Y3'><b id='Nt2Y3'><form id='Nt2Y3'><ins id='Nt2Y3'></ins><ul id='Nt2Y3'></ul><sub id='Nt2Y3'></sub></form><legend id='Nt2Y3'></legend><bdo id='Nt2Y3'><pre id='Nt2Y3'><center id='Nt2Y3'></center></pre></bdo></b><th id='Nt2Y3'></th></span></q></dt></tr></i><div id='Nt2Y3'><tfoot id='Nt2Y3'></tfoot><dl id='Nt2Y3'><fieldset id='Nt2Y3'></fieldset></dl></div>

                            <bdo id='Nt2Y3'></bdo><ul id='Nt2Y3'></ul>