私はこのコードを持っています
<div onclick="location.href='www.example.com'">
<!--Content Here-->
</div>
<div>
<!--Content Here-->
</div>
divwithのインライン CSS スタイルを使用して、次のlocation.hrefようなことができることを知っています。
<div onclick="location.href='www.example.com';" style="cursor:pointer;">
<!--Content Here-->
</div>
インライン スタイルは後で変更するのが面倒なので、この方法は使用したくありませんが
div次のようなスタイリングのために機能するクラスを追加することもできます
<div class="location" onclick="location.href='www.example.com';">
<!--Content Here-->
</div>
.location {cursor:pointer;}
しかし、CSS を使用divしてlocation.href. div:first-child外部スタイルシートを使用してこれらのスタイルを設定したいので、 のようなものは使用できませんlocation.href。純粋にCSSではない場合、jQueryを使用してこれを行う方法はありますか?