开发者

jQuery insertAfter doesn't work in some situations

开发者 https://www.devze.com 2023-01-16 03:07 出处:网络
I want to add a hidden input after some element. I am using this code: $(\"<in开发者_如何学运维put type=\"text\">\").insertAfter(\".addProduct\");

I want to add a hidden input after some element. I am using this code:

$("<in开发者_如何学运维put type="text">").insertAfter(".addProduct");

It doesn't work. But if I replace to it works.

$("<span>ddd</span>").insertAfter(".addProduct");

It works. Help me.

Thank you.


You should use single quotes:

$('<input type="text" />').insertAfter('.addProduct');


If you create this script in php, use this:

$("<input type=\"text\">").insertAfter(".addProduct");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号