【发布时间】:2019-01-29 18:48:14
【问题描述】:
我正在尝试使用 jQuery 根据第一个跨度背景颜色动态更改 div 背景颜色。
<div class="sn-stream-textarea-container">
<span class="sn-stream-input-decorator" style="background-color: #badaff"></span>
<textarea id="activity-stream-comments-textarea" class="sn-string-textarea form-control ng-pristine ng-untouched ng-valid ng-isolate-scope ng-empty ng-valid-required" placeholder="Customer facing notes (Customer visible)" data-stream-text-input="comments" ng-required="activity_field_0.mandatory && !activity_field_0.filled" ng-model="activity_field_0.value" ng-attr-placeholder="{{activity_field_0.label}}" sn-sync-with="activity_field_0.name" sn-sync-with-value-in-fn="reduceMentions(text)" sn-sync-with-value-out-fn="expandMentions(text)" mentio="" mentio-id="'activity-stream-comments-textarea'" mentio-typed-term="typedTerm" mentio-require-leading-space="true" mentio-trigger-char="'@'" mentio-items="members" mentio-search="searchMembersAsync(term)" mentio-template-url="/at-mentions.tpl" mentio-select="selectAtMention(item)" mentio-suppress-trailing-space="true" sn-resize-height="" autocomplete="off" style="overflow: hidden; overflow-wrap: break-word; height: 64px;" aria-invalid="false"></textarea>
</div>
你能帮我指出正确的方向吗?
我试图使用 prop("class") 因为这个 div 没有标识符,但我不确定如何获得 div 内的第一个跨度。
这就是我走了多远。我想我快到了,但找不到元素。 https://jsfiddle.net/rmcardoso/ps1q82zk/6
非常感谢, 拉夫
【问题讨论】: