0
私は次のスクリプトがありますjQueryの文字列は、選択したボタンとその値に基づいて変数が
$(function(){
//all hover and click logic for buttons
$(".fg-button:not(.ui-state-disabled)")
.hover(
function(){
$(this).addClass("ui-state-hover");
},
function(){
$(this).removeClass("ui-state-hover");
}
)
.mousedown(function(){
$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
if($(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active')){ $(this).removeClass("ui-state-active"); }
else {$(this).addClass("ui-state-active");}
})
.mouseup(function(){
if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button, .fg-buttonset-multi .fg-button')){
$(this).removeClass("ui-state-active");
}
});
});
とhtml:
<div class="fg-buttonset fg-buttonset-multi">
<button class="fg-button ui-state-default">Small</button>
<button class="fg-button ui-state-default">Medium</button>
<button class="fg-button ui-state-default">Large</button>
</div>
これは、オンとオフのボタンを切り替えますが、私は、文字列aに必要以下のフォーマットの変数varサイズ:
たとえば、 スモール|中サイズ
選択に基づいて(上の例では中小を選択)
サイズのオプションの数はかなり異なり、必ずしも小さくても大でもないことに注意してください。
ありがとうございました
こんにちは、 返信ありがとうございます。私は、ジョイントは関数ではありませんか? – Dino
おかげで、コードはここで使用されてきたものだ助け:。 $( "FG-buttonset")を各(関数(){\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t VARサイズ= $ (本).find( "UI状態活性")。マップ(関数(){\t \t \t \t \t \t \t \t \t \t retur n $(this).text(); \t \t \t \t \t \t \t \t) \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t VAR引数= $ .makeArray(サイズ).join( "|"); \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t})。 – Dino