javascript - 选择性表格文本颜色更改

标签 javascript html css forms razor

我想在下面的表单代码中将“*”的颜色更改为红色,以便它们更加突出。到目前为止,我还没有找到一种简单的方法来做到这一点。 ,自定义标签在表单中不起作用。

<form name="requestForm" action="requestSent.cshtml" onsubmit="return validateRequest()" method="post">

<label>Email Address: *</label><br>
    <input type="text" name="customerEmail" /><br><br>

<label>First Name: *</label><br>
    <input type="text" name="firstName" /><br>
<label>Last Name: </label><br>
    <input type="text" name="lastName" /><br><br>

<label>Phone Number: </label><br>
    <input type="text" name="phoneNumber" /><br><br>

<label>Request: *</label><br>
    <textarea name="customerRequest" cols="40" rows="4"></textarea>

<p><input type="submit" value="Submit" /></p>

<br>
* Required Fields

最佳答案

为所有 * 设置一个跨度。

<label>Email Address: <span class="red">*</span></label><br>

然后在你的 CSS 中:

<style type="text/css">
 .red{
  color: red;
 }
</style>

关于javascript - 选择性表格文本颜色更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13005594/

相关文章:

javascript - Node.js 中的 Kafka 消费者

javascript - 从左侧滑入内容,覆盖现有内容并插入侧边栏

php - 在 css 中使用 php,substr_count() 搜索文件位置

javascript - JQuery 如何给选定的文本添加 <span> 标签

javascript - 为什么 fusionMap.js 插件会改变 Google map 的起始位置?

javascript - 为什么我的类的构造函数中调用的方法没有按预期工作?

javascript - 停止 hbs 上显示错误的 Webstorm! require.js 的插件

html - 将链接添加到垂直导航菜单

html/css 缩放问题

html - 如何让连续的 nowrap 跨度包装为单独的元素?