占位符未显示
Placeholder is not showing up
echo "<label class=\"control-label col-sm-5\" for=\"badgeid\" style=\"margin-left: -50px;\">Recipient:</label>";
echo "<div class=\"col-sm-4\">";
echo "<p class=\"form-control-static\" style=\"margin-top: -6px;\">";
echo "<input type=\"text\" class=\"form-control\" id=\"reciname\" name=\"reciname\" placeholder=\" Enter Name\" value=\" $reciname\">";
echo "</p>";
echo "</div>";
echo "<div class=\"col-sm-10\"></div>";
在上面的代码中,占位符没有出现在框中。我该如何解决?
您的代码似乎有效。这是一个测试:https://www.tehplayground.com/e9h6UnMdcERDjZ3A
据我了解,您正在尝试让 <input>
字段包含 Enter Name
。
在 HTML 中,占位符用于在 input
为空时提供文本。当您有一个与之关联的值时(在本例中为 $reciname
,当前值为 test
),占位符将不会显示。
要显示占位符,您无需为变量赋值(或仅用引号)$reciname
。
示例:
<?php
//this allows the value to be blank and the placeholder to show.
//if this is assigned a value, then the placeholder will not show, instead it
//will be the value
$reciname="";
echo "<label class=\"control-label col-sm-5\" for=\"badgeid\" style=\"margin-left: -50px;\">Recipient:</label>";
echo "<div class=\"col-sm-4\">";
echo "<p class=\"form-control-static\" style=\"margin-top: -6px;\">";
echo "<input type=\"text\" class=\"form-control\" id=\"reciname\" name=\"reciname\" placeholder=\"Enter Name\" value=\"$reciname\">";
echo "</p>";
echo "</div>";
echo "<div class=\"col-sm-10\"></div>";
?>
文档:
<input>
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
placeholder
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
value
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
echo "<label class=\"control-label col-sm-5\" for=\"badgeid\" style=\"margin-left: -50px;\">Recipient:</label>";
echo "<div class=\"col-sm-4\">";
echo "<p class=\"form-control-static\" style=\"margin-top: -6px;\">";
echo "<input type=\"text\" class=\"form-control\" id=\"reciname\" name=\"reciname\" placeholder=\" Enter Name\" value=\" $reciname\">";
echo "</p>";
echo "</div>";
echo "<div class=\"col-sm-10\"></div>";
在上面的代码中,占位符没有出现在框中。我该如何解决?
您的代码似乎有效。这是一个测试:https://www.tehplayground.com/e9h6UnMdcERDjZ3A
据我了解,您正在尝试让 <input>
字段包含 Enter Name
。
在 HTML 中,占位符用于在 input
为空时提供文本。当您有一个与之关联的值时(在本例中为 $reciname
,当前值为 test
),占位符将不会显示。
要显示占位符,您无需为变量赋值(或仅用引号)$reciname
。
示例:
<?php
//this allows the value to be blank and the placeholder to show.
//if this is assigned a value, then the placeholder will not show, instead it
//will be the value
$reciname="";
echo "<label class=\"control-label col-sm-5\" for=\"badgeid\" style=\"margin-left: -50px;\">Recipient:</label>";
echo "<div class=\"col-sm-4\">";
echo "<p class=\"form-control-static\" style=\"margin-top: -6px;\">";
echo "<input type=\"text\" class=\"form-control\" id=\"reciname\" name=\"reciname\" placeholder=\"Enter Name\" value=\"$reciname\">";
echo "</p>";
echo "</div>";
echo "<div class=\"col-sm-10\"></div>";
?>
文档:
<input>
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
placeholder
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
value
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value