我想在输入attr标题上添加div基础,我的意思是说我想添加div我输入的标题=毕业日期
<div class="personalisation_input">
<input type="text" value="" title="date-of-graduation">
</div>
<div class="personalisation_input">
<input type="text" value="" title="date-of-age">
</div>
<div class="personalisation_input">
<input type="text" value="" title="date-of-graduation">
</div>
需要输出
<div class="personalisation_input">
<input type="text" value="" title="date-of-graduation">
<div>test</div>
</div>
<div class="personalisation_input">
<input type="text" value="" title="date-of-age">
</div>
<div class="personalisation_input">
<input type="text" value="" title="date-of-graduation">
<div>test</div>
</div>
答案 0 :(得分:3)
您可以使用"attribute equals" selector选择正确的input
元素,并使用.after()
方法在其后面插入一些内容:
$("input[title='date-of-graduation']").after("<div>test</div>");
答案 1 :(得分:0)
$('.personalisation_input input').each(function(){
if($(this).attr('title') == 'date-of-graduation'){
$(this).after('<div>Test</div>')
}
});
答案 2 :(得分:0)
$("input[title='date-of-graduation']").parent().append("<div>test</div>");