だから私はここの別の投稿でこのスクリプトを見つけて、私のスタイル/サイトに合うように変更しましたが、1 div でしか機能しません。同じページの複数の div で使用したいのですが、div を複製するとそのうちの 1 つだけが機能します。すべての div に同じ名前が付けられているため、機能する必要がありますか、それとも各 div に異なる名前を付ける必要がありますか? コーディングを行って編集することなく、投稿からプルして自動表示するように設定しているため、不要な場合はすべてのコーディングを追加する必要がないようにしています。
これは私が現在使用しているコーディングです。左側のものは機能しますが、私が広告を追加したものは、カーソルを合わせると機能しません。
HTML
<div id="client" style="float:left;">
<div id="client_slider">
<p>content...</p>
</div>
</div>
<div id="client" style="float:left;">
<div id="client_slider">
<p>content...</p>
</div>
</div>
CSS
#client {
position: relative;
overflow:hidden;
background-color:#ffff00;
width: 320px;
height: 320px;
}
#client_slider {
width: 320px;
height: 320px;
bottom: -320px;
right: 0px;
background-color: rgba(0, 0, 0, 0.7);
position: absolute;
color:#fff;
}
脚本
$(function () {
$('#client').on("mouseenter", function () {
$("#client_slider").animate({
"bottom": "-240px"
}, "slow");
}).on("mouseleave", function () {
$("#client_slider").animate({
"bottom": "-320px"
}, "fast");
});
});
サンプルリンク