0

select#categoryを参照して、どれが要素 ID ですか? これも説明できselect option:selectedますか?

$("select#category").change(function () 
{
  if ($("select option:selected").val() == 0) {
   $('div[id^="product_"]').hide();
   $('#waiting').show();
}
   $('#waiting').hide();
   $('div[id^="product_"]').hide();
   if ($('div[id="product_'+$("select option:selected").val()+'"]:visible')) 
   {
     $('div[id="product_'+$("select option:selected").val()+'"]').show();
   }
}
});

「id」が関係している場合、そこに select キーワードを配置するのはなぜですか?

4

1 に答える 1

3

select#category
selectid を持つ要素を参照しますcategory

select option:selected
optionページ内の要素の下で 選択さselectれた を参照します (注: 複数の要素を返すことができます)

この場合、置き換えたいと思うかもしれません$("select option:selected").val()-$(this).val()それは選択されたオプションの値を与えます

于 2013-07-25T07:05:10.660 に答える