仅当更改值等于行业价值时才使用jQuery

时间:2011-09-07 02:11:33

标签: jquery live

只是想知道我有一个选择框,当我更改时,我希望它显示该选择值的子类别。我需要做的部分怎么做只包括有行业的价值:1我知道如何进行实时更改并调用此函数,我不知道该怎么做,是如何做一个IF语句只做它显示符合1

的行业
function industrytype(e){
var industryselect = [
  {Code:1, industry:1, Name:"Automotive"},
  {Code:2, industry:1, Name:"Daily Needs"},
  {Code:3, industry:1, Name:"Fashion"},
  {Code:4, industry:2, Name:"For The Loved Ones"},
  {Code:5, industry:3, Name:"Health & Beauty"},
  {Code:6, industry:3, Name:"Home Maker"},
  {Code:7, industry:3, Name:"Jewellery"},
  {Code:8, industry:3, Name:"Restaurant & Cafes"},
  {Code:9, industry:4, Name:"Sports & Entertainment"},
  {Code:10, industry:4, Name:"Trade Services"},
  {Code:11, industry:4, Name:"Travel & Leisure"}
];  

 var industrySelector = $('select[name=industry]');
    $.each(industryselect, function(index,industryselect) {
        $('<option />', {
            selected: e === industryselect.Code,
            value: industryselect.Code,
            text: industryselect.Name
        }).appendTo(industrySelector)   


    }); 
}

0 个答案:

没有答案