Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$("div:contains(' 1434')").parent().addClass('date');
クラスはすべての div に追加されます。クラス/IDが役立つことはわかっていますが、htmlはタグスープであり、それについては何もできません。テキストを直接含む要素だけに一致を制限する方法はありますか?
has親要素notを取得し、最も内側の要素を取得するために使用できます。
has
not
var d = $('div:contains(" 1434")'); var p = d.has(d); d.not(p).parent().addClass('border');
デモ: http://jsfiddle.net/Guffa/JFHjG/