2011-12-18 9 views

答えて

1

$("#autoplay option:selected").attr("data-autoplay"); 

または

$("#autoplay option:selected").data("autoplay"); 
、次のコードを試してみてください
1

あなたは、属性の値を取得するにはattr()メソッドを使用することができます返すnoを選択します。

var autopplay = $('#autoplay option:selected').attr('data-autoplay'); 

if (!autoplay || autoplay == '') { 
    // an empty string was returned 
} 
else if (autoplay == 1) { 
    /* remember not to trust your users, so validate in/on the server 
     if you're storing the variable/result... 
    // 1 was returned 
} 

この場合には、それがためになりますので、それは、data-次のセレクタにマッチする文字列(自動再生)とdata-接頭辞の属性を見ていきますこれは、またdata('autoplay')を使用することが可能です:やや明らかにdata-autoplay(私は仮定し、 )。

参考文献:

関連する問題