jQuery .append不起作用 [英] jQuery .append doesn't work

查看:126
本文介绍了jQuery .append不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表单中插入一些内容,该形式在插件中进行了硬编码,并且我不想弄乱插件文件,所以我找到了.append

I want to insert something into my form, which is somewhere hard coded into plugin and I didn't want to mess with the plugin files, so I've found .append

<script>jQuery('#edit-profile').append('<p>smth</p>');</script>

我写了这样的东西,据我所知它应该起作用. Chrome中的控制台不会显示任何错误.这里有问题吗?

I've written something like this and as far as I can see it should work. Console in Chrome doesn't shows me any bugs. Is here something wrong?

由于wordpress安全模式,我正在使用最新的jQuery,并使用jQuery而不是$.

I'm using the newest jQuery and using jQuery instead of $ due to the wordpress safemode.

推荐答案

将其包装在dom中.因为在执行脚本时#edit-profile应该在其中,

Wrap it in dom ready.Because #edit-profile should be there at the time of executing the script,

jQuery(document).ready(function(){
  jQuery('#edit-profile').append('<p>smth</p>');
});

这篇关于jQuery .append不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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