私は次の構造を持っています:
<div id="content-header">
<h1 id="title">Athletics Calendar</h1>
</div>
h1タグの後にいくつかのリンクを追加する次のjquery
$(document).ready(function() {
$("body[class*=page-calendar-practices] #content-header h1#title").after("<div id='athletics_practice-schedule'><div id='inner-title'><a href='calendar/practices/games' class='athletics_links'>GAMES</a><a href='calendar/practices' class='athletics_links'>PRACTICES</a></div></div>");
});
リンクが表示されますが、挿入していた外側の div に -15px のマージンを設定する必要があったため (div をシフトするために... 技術的な理由でこれを行う必要がありました)、リンクにカーソルを合わせると何も表示されませんが、そのすぐ下にカーソルを合わせると表示されます。これを修正する方法はありますか?別の投稿で、誰かが以下のコードを使用してリンクを変更することを提案しましたが、機能せず、何も色が変わっていないため、それをどのように利用するかさえわかりません。
$(document).on('mouseenter', 'body[class*=page-calendar-practices] #content-header div#inner-title', function() {
$(this).css('color','red !important');
}).on('mouseleave', 'body[class*=page-calendar-practices] #content-header div#inner-title', function() {
$(this).css('color','blue !important');
});