下面的代码工作正常,但是如果没有选定的属性或者是空的,我想隐藏.search-form #city。提前谢谢你的时间。
$('.search-form #city').parent().hide()
cities = $('.search-form #city').html()
$('.search-form #country').change ->
country = $('.search-form #country :selected').text()
escaped_country = country.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')
options = $(cities).filter("optgroup[label='#{escaped_country}']").html()
if options
$('.search-form #city').html(options)
$('.search-form #city').parent().show()
else
$('.search-form #city').empty()
$('.search-form #city').parent().hide()发布于 2013-11-19 21:45:17
if($('.search-form #city').find('option').length==0 || $('.search-form #city').find(':selected').length==0)
$('.search-form #city').hide();https://stackoverflow.com/questions/20081895
复制相似问题