当dropdownlist selectedvalue时激发jquery函数
我有一个jqueryanimate函数,如果下拉列表的selectedvalue是X,我想调用它当dropdownlist selectedvalue时激发jquery函数,jquery,asp.net,function,drop-down-menu,selectedvalue,Jquery,Asp.net,Function,Drop Down Menu,Selectedvalue,我有一个jqueryanimate函数,如果下拉列表的selectedvalue是X,我想调用它 <script> $(function () { var state = true; ($("#button").click)(function () { if (state) { $("#effect").animate({ backgr
<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;
});
});
$(函数(){
var状态=真;
($(“#按钮”)。单击)(函数(){
如果(州){
$(“#效果”)。设置动画({
背景颜色:“aa0000”,
颜色:“fff”,
宽度:500
}, 1000);
}否则{
$(“#效果”)。设置动画({
背景颜色:“fff”,
颜色:“000”,
宽度:500
}, 1000);
}
状态=!状态;
});
});
您可以这样尝试 <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;
});
});
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;
});
});
下拉列表id->DDL下拉列表
<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;
});
});
$(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;
});
});
这里也有很多格式问题,这看起来像是一个
。单击事件而不是。更改()
一个下拉列表,就像你说的那样。我同意事件应该写在下拉列表上,而不是按钮上。这是一个可以帮助你的