我有一个jQuery动画函数,如果我的下拉列表的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;
});
});
答案 0 :(得分: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;
});
});
答案 1 :(得分:0)
DropDown id - &gt; 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;
});
});