我正在使用在ajax调用后显示的模式中输入的bootstrap标记。
现在,我想将"form-control“类添加到生成的input标记中。
我试过这样做:
$(".bootstrap-tagsinput >input“).addClass(‘表单控件’);
但它对我不起作用。
下面是生成的输入:
<div class="bootstrap-tagsinput">
<input type="text" placeholder="">
</div>有什么想法吗?
发布于 2021-11-25 14:42:22
你不需要>符号
$(".bootstrap-tagsinput input").addClass('form-control');<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="bootstrap-tagsinput">
<input type="text" placeholder="">
</div>
参考资料:
- [Child combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator)https://stackoverflow.com/questions/70113010
复制相似问题