我的内容是由我正在使用的软件自动生成的,我需要将松散的字符串包装在一个类中,以便我可以设置它。
$('label.ng-binding').wrapInner('<div class="rpc_cb"></div>');
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<label class="ng-binding">
<input class="checking"
ng-model="model[options.key]"
id="formly_1_checkbox_email-accepts_email_8"
name="email.accepts_email"
formly-custom-validation=""
type="checkbox">
Yes, I would like to receive email from this site.
</label>
&#13;
WrapInner将包装所有内容,但我需要定位&#34;是的,我希望收到来自此网站的电子邮件。&#34;
谢谢!
答案 0 :(得分:1)
$('label.ng-binding')
.contents()
.filter(function() {
return this.nodeType === 3;
})
.wrap( '<div class="rpc_cb"></div>' );
.rpc_cb{
color:red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<label class="ng-binding"><input class="checking" ng-model="model[options.key]" id="formly_1_checkbox_email-accepts_email_8" name="email.accepts_email" formly-custom-validation="" type="checkbox">
Yes, I would like to receive email from this site.
</label>
试试这个,然后设置课程。然后你可以设计它。