使用javascript在文本框中放置图标 [英] Placing an icon in a textbox using javascript
本文介绍了使用javascript在文本框中放置图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在文本框中添加图标时遇到问题,任何人都可以帮忙解决这个问题。
< script 类型 = text / javascript >
$(document).ready(function(){
$(#add)。click(function() {
var intId = $(#buildyourform div)。length + 1;
var fieldWrapper = $();
var fchk = $(< 输入 类型 = \ checkbox \ class = \ fieldcheck \ / > )
var fName = $(< input 类型 = \ text \ class = < span class =code-keyword> \ form-control \ 占位符 = \ 用户名\ / >
var removeButton = $(< input type = \ button \ class = \ remove\ value < span class =code-keyword> = \ - \ / > );
removeButton.click(function(){
$(this).parent()。remove();
});
fieldWrapper.append(fchk);
fieldWrapper.append(fName);
fieldWrapper.append(removeButton);
$(#buildyourform)。append(fieldWrapper);
});
});
< / script >
但是文本框外面的图标显示任何一个帮助
解决方案
< blockquote>(document).ready(function(){
(#add)。click(function(){
var intId =
(#buildyourform div)。length + 1;
var fieldWrapper =
am facing problem while adding an icon in my textbox can any one help out with this.
<script type="text/javascript">
$(document).ready(function() {
$("#add").click(function() {
var intId = $("#buildyourform div").length + 1;
var fieldWrapper = $("");
var fchk = $("<input type="\"checkbox\"" class="\"fieldcheck\"" /> ")
var fName = $("<input type=\"text\" class=\"form-control\" placeholder=\"Username\" />
var removeButton = $("<input type="\"button\"" class="\"remove\"" value="\"-\"" />");
removeButton.click(function() {
$(this).parent().remove();
});
fieldWrapper.append(fchk);
fieldWrapper.append(fName);
fieldWrapper.append(removeButton);
$("#buildyourform").append(fieldWrapper);
});
});
</script>
but the icon displays outside the text box can any one help with this
解决方案
(document).ready(function() {
("#add").click(function() { var intId =
("#buildyourform div").length + 1; var fieldWrapper =
这篇关于使用javascript在文本框中放置图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文