简体   繁体   English

找到星号并在表单标签中更改为红色[Meteor JS Way]

[英]Find Asterisk and change to red color in form label [Meteor JS Way]

Consider SimpleSchema , 考虑SimpleSchema

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

On UI it appears as below, 用户界面上,它显示如下,

在此处输入图片说明

We mostly write javascript in below peice of code, 我们主要在以下代码中编写javascript,

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

View Source looks like below, 查看源代码如下所示,

<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>

How can I change the color of asterisk? 如何更改星号的颜色? I tried various other articles on same query but I could not resolve it. 我在同一查询中尝试了其他各种文章,但无法解决。

You'll likely want to append the asterisk using a pseudo-element in CSS. 您可能需要在CSS中使用伪元素附加星号。 For example, 例如,

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

Then style it: 然后设置样式:

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

No need for anything Meteor-specific here! 这里不需要任何流星特有的东西!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM