append不适用于动态添加的元素 [英] append do not work for dynamically added elements

查看:73
本文介绍了append不适用于动态添加的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  if ($( #mce_21-body)。append($(  #color)。html())){ console  .log( 附加);}  else   console  .log( 失败); 







这里`

 <   div  < span class =code-attribute>   id   = #mce_21-body >  ... <   / div  >  

`动态创建的元素。这个元素我想附加'

 <   div     id   =  color >  <  输入    type   = < span class =code-keyword> text    /  >  <   / div  >  

`执行jQuery代码后没有显示'Console'显示附加。但实际上没有添加元素。我这样做,我也试过' .ready()'function。

决方案

#mce_21-body)。append(


#color)。html())){ console .log( attach) ;} else console .log( 失败);







这里`

 <   div     id   = #mce_21-body  >  ... <   / div  >  

`动态创建元素。这个元素我想附加'

 <   div     id   =  color >  <  输入    type   = < span class =code-keyword> text    /  >  <   / div  >  

`执行jQuery代码后没有显示'Console'显示附加。但实际上没有添加元素。我这样做,我也试过' .ready()'function。


你的mce_21-body id不正确

 <   div     id   = #mce_21-body >  ... < ;   / div  >  



应该是

 <   div     id   =  mce_21-body >  ... <  < span class =code-leadattribute> / div  >  



这个

 


if( $("#mce_21-body").append($("#color").html())){console.log("appended");}else console.log("failed");




Here `

<div id="#mce_21-body">...</div>

` dynamically created element. This element i want to append '

<div id="color"><input type="text" /></div>

` not showing after the execution of jQuery code 'Console' shows "appended".But actually the element not added .how i do that,i also tried '.ready()' function .

解决方案

("#mce_21-body").append(


("#color").html())){console.log("appended");}else console.log("failed");




Here `

<div id="#mce_21-body">...</div>

` dynamically created element. This element i want to append '

<div id="color"><input type="text" /></div>

` not showing after the execution of jQuery code 'Console' shows "appended".But actually the element not added .how i do that,i also tried '.ready()' function .


Your mce_21-body id is incorrect

<div id="#mce_21-body">...</div>


should be

<div id="mce_21-body">...</div>


And this


这篇关于append不适用于动态添加的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆