【问题标题】:Find Asterisk and change to red color in form label [Meteor JS Way]在表单标签中找到星号并更改为红色 [Meteor JS 方式]
【发布时间】:2018-02-19 22:10:45
【问题描述】:

考虑 SimpleSchema

ClientsSchema = new SimpleSchema({
  "firstName": {
    type: String,
    label: "First Name *",
    max: 20
  }
});

UI上显示如下,

我们主要在以下代码中编写 javascript,

Template.Name.onRendered(function(){});

查看源代码如下所示,

<div class="col-sm-3">
    <div class="form-group" data-required="true">
        <label for="8fmieRFmLkqYQ5XFF" class="control-label">First Name *</label>
        <input type="text" name="firstName" id="8fmieRFmLkqYQ5XFF" required="" data-schema-key="firstName" 
            maxlength="20" class="form-control">
        <span class="help-block"></span>
    </div>
</div>

如何更改星号的颜色?我在同一个查询上尝试了各种其他文章,但我无法解决它。

【问题讨论】:

  • 你问的是如何动态地改变星号的颜色还是静态地改变?

标签: javascript html css meteor ecmascript-6


【解决方案1】:

您可能希望在 CSS 中使用伪元素附加星号。例如,

ClientsSchema = new SimpleSchema({
  "firstName": {
    type: String,
    label: "First Name", // remove asterisk from here
    max: 20
  }
});

然后设置样式:

.form-group[data-required="true"] .control-label::after {
  content: '*';
  display: inline-block;
  color: red;
}

这里不需要任何 Meteor 特定的东西!

【讨论】:

  • 非常感谢您的回复,将尽快测试。
猜你喜欢
  • 1970-01-01
  • 2019-06-18
  • 2018-10-29
  • 2020-03-10
  • 1970-01-01
  • 2017-08-06
  • 2014-05-26
  • 1970-01-01
相关资源
最近更新 更多