私はこのコードを持っています
<div onclick="location.href='www.example.com'">
<!--Content Here-->
</div>
<div>
<!--Content Here-->
</div>
div
withのインライン 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を使用してこれを行う方法はありますか?