我想换掉
$('#topspeed').change(function(){有一个条件,类似于下面的条件,但可以工作
if($("[id=topspeed]").is(":selected")){ 该怎么做呢?
发布于 2013-06-23 11:27:52
从jQuery文档
:selected选择器适用于它不适用于复选框或单选输入的元素,
您似乎可以直接在select元素上使用它。
你可以写这样的代码。
if($('#topspeed option[value="1"]').is(":selected")) { 编辑
由于语法错误而无法工作
$('select').change(function () {
if ($(this).is('#topspeed') {
^------ Missing Closing brace
alert('Shrubs has been selected')
})
^------ Not supposed to be here
})发布于 2013-06-23 21:41:51
这就是答案:
$('select').change(function(){
if($(this).is('#topspeed'))谢谢。
https://stackoverflow.com/questions/17257446
复制相似问题