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.
私は次のことをしようとしています。
「open」クラスの親 div がある場合は、クラス「on」を要素 (h3) に追加します。
Jクエリ
$('h3').parent('.open').addClass('on');
簡単なjqueryの例を見ていくとわかると思います。次のスニペットが役立ちます。
$('h3').each(function(){ if($(this).parent().attr("class")=="open"){ $(this).attr("class","on") } });
次の 1 行のコードでも同じ出力が得られます。
$(".open h3").attr('class',"on");