注目のスライダーの関数を書き込もうとしています。
基本的に、あるページでは回転速度を 10000 に、別のページでは速度を 3000 にします。
私は2つの機能を別々に持っています-これは機能します-しかし、すべてのコードを繰り返さずにそれを行うためのよりクリーンでより良い方法があることを知っています...
誰でも助けることができますか?
$(function(){
$("body.homePage #featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 10000, true);
$("body.homePage #featured").hover(
function() {
$("body.homePage #featured").tabs("rotate",0,true);
},
function() {
$("body.homePage #featured").tabs("rotate",10000,true);
}
);
});
$(function(){
$("body.boatDetailsPage #featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 3000, true);
$("body.boatDetailsPage #featured").hover(
function() {
$("body.boatDetailsPage #featured").tabs("rotate",0,true);
},
function() {
$("body.boatDetailsPage #featured").tabs("rotate",3000,true);
}
);
});
何かのようなもの
if ($('body').hasClass('homePage')) {
$("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 10000, true);
$("#featured").hover(
function() {
$("#featured").tabs("rotate",0,true);
},
function() {
$("#featured").tabs("rotate",10000,true);
}
);
} else {
$("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 3000, true);
$("#featured").hover(
function() {
$("#featured").tabs("rotate",0,true);
},
function() {
$("#featured").tabs("rotate",3000,true);
}
);
}