0

我目前一直在玩 jquery.chained.js 并让它在 FF、IE8+、Safari、Chrome 中工作......问题是在 IE7 中,无论选择什么选项,它都会显示所有值。这是我的代码。

  <script type="text/javascript" charset="utf-8">  
  $(function() {

/* For jquery.chained.js */
$("#year").chained("#make");
$("#model").chained("#year");

$("#button").attr("disabled", true);
$("#model").bind("change", function(event) {
    if ("" != $("option:selected", this).val() && "" != $("option:selected", $("#model")).val()) {
      $("#button").attr("disabled", false);
    } else {
        $("#button").attr("disabled", true);          
    }
});

});

 <select style="width:125px" name="make" id="make">
      <option value="">Make</option>
      <option value="Ford">Ford</option>
      <option value="GM">GM</option>
      <option value="Other">Other</option>
    </select>
    <select style="width:125px" name="year" id="year">
      <option value="">Year</option>

      <option value="FordYear1" class="Ford">Ford Year Range 1</option>
      <option value="FordYear2" class="Ford">Ford Year Range 2</option>
      <option value="FordYear3" class="Ford">Ford Year Range 3</option>


      <option value="1991-1992" class="GM">1991-1992</option>
      <option value="1993+" class="GM">1993+</option>
      <option value="1993-1995" class="GM">1993-1995</option>
      <option value="1996+" class="GM">1996+</option>
      <option value="2006-2008" class="GM">2006-2008</option>
      <option value="2009+" class="GM">2009+</option>

      <option value="OtherYear1" class="Other">Other Year Range 1</option>
      <option value="OtherYear2" class="Other">Other Year Range 2</option>
      <option value="OtherYear3" class="Other">Other Year Range 3</option>

    </select>
    <select style="width:125px" name="model" id="model">
      <option value=""><i>Model</i></option>

      <option value="FordYear1Model1"       class="FordYear1">Ford Year Range 1 Model 1</option>
      <option value="FordYear1Model2"       class="FordYear1">Ford Year Range 1 Model 2</option>
      <option value="FordYear1Model3"         class="FordYear1">Ford Year Range 1 Model 3</option>

      <option value="FordYear2Model1"       class="FordYear2">Ford Year Range 2 Model 1</option>
      <option value="FordYear2Model2"       class="FordYear2">Ford Year Range 2 Model 2</option>
      <option value="FordYear2Model3"         class="FordYear2">Ford Year Range 2 Model 3</option>

      <option value="FordYear3Model1"       class="FordYear3">Ford Year Range 3 Model 1</option>
      <option value="FordYear3Model2"       class="FordYear3">Ford Year Range 3 Model 2</option>
      <option value="FordYear3Model3"         class="FordYear3">Ford Year Range 3 Model 3</option>


      <option value="4L80E or 4L85E"       class="1991-1992">4L80E or 4L85E</option>
      <option value="4L80E or 4L85E"       class="1993+">4L80E or 4L85E</option>
      <option value="4L60E or 4L65E"         class="1993-1995">4L60E or 4L65E</option>

      <option value="4L60E or 4L65E"       class="1996+">4L60E or 4L65E</option>
      <option value="4L70E"               class="2006-2008">4L70E</option>
      <option value="4L70E or 4L75E"         class="2009+">4L70E or 4L75E</option>


      <option value="OtherYear1Model1"       class="OtherYear1">Other Year Range 1 Model 1</option>
      <option value="OtherYear1Model2"       class="OtherYear1">Other Year Range 1 Model 2</option>
      <option value="OtherYear1Model3"         class="OtherYear1">Other Year Range 1 Model 3</option>

      <option value="OtherYear2Model1"       class="OtherYear2">Other Year Range 2 Model 1</option>
      <option value="OtherYear2Model2"       class="OtherYear2">Other Year Range 2 Model 2</option>
      <option value="OtherYear2Model3"         class="OtherYear2">Other Year Range 2 Model 3</option>

      <option value="OtherYear3Model1"       class="OtherYear3">Other Year Range 3 Model 1</option>
      <option value="OtherYear3Model2"       class="OtherYear3">Other Year Range 3 Model 2</option>
      <option value="OtherYear3Model3"         class="OtherYear3">Other Year Range 3 Model 3</option>   
    </select>
4

1 回答 1

0

尝试

$(this).val() 代替$("option:selected", this).val()

$("#model")).val()代替$("option:selected", $("#model")).val())

于 2012-05-23T15:02:56.333 回答