1

我有一个 jQuery animate 函数,如果我的下拉列表的 selectedvalue 是 X,我想调用它

       <script>
    $(function () {
        var state = true;
        ($("#button").click)(function () {
            if (state) {
                $("#effect").animate({
                    backgroundColor: "#aa0000",
                    color: "#fff",
                    width: 500
                }, 1000);
                  } else {
                $("#effect").animate({
                    backgroundColor: "#fff",
                    color: "#000",
                    width:500

                }, 1000);
            }
            state = !state;
        });
    });
4

2 回答 2

0

你可以试试这样

jQuery(document).ready(function(){
    var state = true;
  $("#otherCatches").change(function() {
      if (state) {
            $("#effect").animate({
                backgroundColor: "#aa0000",
                color: "#fff",
                width: 500
            }, 1000);
              } else {
            $("#effect").animate({
                backgroundColor: "#fff",
                color: "#000",
                width:500

            }, 1000);
        }
        state = !state;

   });
});
于 2012-11-06T04:57:32.907 回答
0

下拉 id -> ddlDropDown

      $(document).ready(function(){
          var state = true;
        $("#ddlDropDown").change(function() {
             if ($("#ddlDropDown").val()=="X") { //Checking if value is X
                $("#effect").animate({
                     backgroundColor: "#aa0000",
                     color: "#fff",
                     width: 500
                  }, 1000);
              } else {
               $("#effect").animate({
               backgroundColor: "#fff",
               color: "#000",
               width:500

        }, 1000);
      }
      state = !state;
  });
});
于 2012-11-06T05:57:58.410 回答