I'm trying to check in jQuery if a div contains some text, and then add a class if it does.
So I wrote something like this:
if( $("#field > div.field-item").text().indexOf('someText') = 0) {
$("#somediv").addClass("thisClass");
}
I'm not getting this to work.
<div id="field"><div class="field-item">someText</div></div>
<div id="somediv"></div>
Is this incorrect?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…