Html 如何使用引导将glyphicon放置在输入表单中的占位符中
我正试图通过引导使用占位符将字形图标放置在输入表单中 但其结果是以输入形式显示代码,而不是以图标的形式显示 这是我的密码:Html 如何使用引导将glyphicon放置在输入表单中的占位符中,html,css,twitter-bootstrap,Html,Css,Twitter Bootstrap,我正试图通过引导使用占位符将字形图标放置在输入表单中 但其结果是以输入形式显示代码,而不是以图标的形式显示 这是我的密码: 输出: 显示为 <span class="glyphicon glyphicon-search">search 搜索 在输入表单中 对不起,问题不清楚 实际上应该是当我点击输入表单并输入一些文本时,当我们放置在占位符中时,字形图标应该隐藏起来 提前谢谢。像这样试试 <!DOCTYPE html> <html> <ti
输出: 显示为
<span class="glyphicon glyphicon-search">search
搜索
在输入表单中
对不起,问题不清楚 实际上应该是当我点击输入表单并输入一些文本时,当我们放置在占位符中时,字形图标应该隐藏起来 提前谢谢。像这样试试
<!DOCTYPE html>
<html>
<title>Timer</title>
<head>
<link href="css/bootstrap.css" type="text/css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-2.1.3.js"></script>
<script>
jQuery(function(){
$('#exampleInputAmount').blur(function(){
var textValue = $(this).val(); // GETTING TEXT BOX VALUE
if(textValue != '') {
$('.glyphicon-search').parent().hide(); // HIDDING DIV IF TEXT BOX IF NOT EMPTY
} else {
$('.glyphicon-search').parent().show(); // SHOWING DIV IF TEXT BOX IF EMPTY
}
});
});
</script>
</head>
<body>
<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-search"></div>
<input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
<div class="input-group-addon"><span class="glyphicon glyphicon-search"></div>
</div>
</div>
</form>
</body>
</html>
计时器
jQuery(函数(){
$('#exampleInputAmount').blur(函数(){
var textValue=$(this).val();//获取文本框值
如果(textValue!=''){
$('.glyphicon search').parent().hide();//如果文本框不为空,则隐藏DIV
}否则{
$('.glyphicon search').parent().show();//如果文本框为空,则显示DIV
}
});
});
金额(美元)
此外,您可以参考下面的URL,它为许多bootstap相关问题提供了语法和格式
这个问题在这里已经有了答案:嘿,我得到了文本形式的glyphicons,谢谢。但是当我们在输入表单中输入文本时,我需要隐藏glyphicons(与占位符相同)。为此,您必须使用一些jquery工具,可以吗?此外,这可能会有帮助,如果你对jQuery的东西没意见,请告诉我对不起,我不理解jQuery,但我正在尝试使用示例代码。
<!DOCTYPE html>
<html>
<title>Timer</title>
<head>
<link href="css/bootstrap.css" type="text/css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-2.1.3.js"></script>
<script>
jQuery(function(){
$('#exampleInputAmount').blur(function(){
var textValue = $(this).val(); // GETTING TEXT BOX VALUE
if(textValue != '') {
$('.glyphicon-search').parent().hide(); // HIDDING DIV IF TEXT BOX IF NOT EMPTY
} else {
$('.glyphicon-search').parent().show(); // SHOWING DIV IF TEXT BOX IF EMPTY
}
});
});
</script>
</head>
<body>
<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-search"></div>
<input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
<div class="input-group-addon"><span class="glyphicon glyphicon-search"></div>
</div>
</div>
</form>
</body>
</html>