本文介绍了如何在另一个元素之后添加一个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个特定的文本框,我想在其后添加一个div。
我已经尝试过 .append()
函数,但这只会在元素中添加div。
I have a certain textbox and I want to add a div after it.I've tried the .append()
function, but that only adds the div in the element.
例如,我有:
<input type="text" id="bla" />
,我想将其更改为:
<input type="text" id="bla" /><div id="space"></div>
推荐答案
尝试使用 after( )
方法:
$('#bla').after('<div id="space"></div>');
这篇关于如何在另一个元素之后添加一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!