我有一個身體地圖上有多個觸發點。我想要一個裝滿標題和副本的獨特盒子,以顯示每個觸發點懸停的情況。我一次寫出了一個函數,但我想寫一個更清晰,更簡潔的函數。這是我到目前爲止:多個懸停和動畫實例與jQuery
$(".point-one").hover(
function() {
$("#patient-body").animate({opacity: 0.3});
$(".trigger-point").animate({opacity: 0.1});
$("#service-one").animate({opacity: 1.0});
},
function() {
$("#patient-body").delay(100).animate({opacity: 1.0}, "fast");
$(".trigger-point").delay(100).animate({opacity: 1.0}, "fast");
$("#service-one").delay(100).animate({opacity: 0}, "fast");
});
$(".point-two").hover(
function() {
$("#patient-body").animate({opacity: 0.3});
$(".trigger-point").animate({opacity: 0.1});
$("#service-two").animate({opacity: 1.0});
},
function() {
$("#patient-body").delay(100).animate({opacity: 1.0}, "fast");
$(".trigger-point").delay(100).animate({opacity: 1.0}, "fast");
$("#service-two").delay(100).animate({opacity: 0}, "fast");
}
);
我怎樣才能更有效地寫這個?
容納這是HTML:
<a href="#" class="trigger-point point-one">Shoulder</a>
<div id="service-one" class="fpt-service">
<h3>Shoulder</h3>
<p>We treat arthritis, dislocation, frozen shoulder, tendinitis, rotator cuff tears, post surgical arthroscopy, and other conditions that inhibit range of motion.</p>
</div>
<a href="#" class="trigger-point point-two">Back</a>
<div id="service-two" class="fpt-service">
<h3>Back</h3>
<p>Back conditions that we treat include arthritis, herniated discs, ligamentous strains, lumbar radiculopathy, rhombois and lower trapezius strain, muscular strains, osteoporosis, scoliosis, spinal stenosis, T4 syndrome and upper back stiffness.</p>
</div>
是的!太棒了。謝謝!!! – 2011-05-09 15:20:09