我根据这个网址(http://jsfiddle.net/3UWk2/1/) 的内容在iPhone中进行实验。但是在JavaScript中好像无法正常运行。请高手给点建议,谢谢。
<script>
$(document).ready(function() {
$('#00Ni0000007XPVF').bind('change', function() {
var elements = $('div.container_drop').children().hide(); // hide all the elements
var value = $(this).val();
if (value.length) { // if somethings' selected
elements.filter('.' + value).show(); // show the ones we want
}
}).trigger('change');
});
</script>
你是不是用了缓存值。hide没有返回任何信息,因此在你尝试再次显示时失败:
var elements = $('div.container_drop').children().hide();
应该是:
var elements = $('div.container_drop').children();
elements.hide();
代码:
$(document).ready(function() {
$('#00Ni0000007XPVF').bind('change', function() {
// cache the value
var elements = $('div.container_drop').children();
elements.hide(); // hide all the elements
var value = $(this).val();
if (value.length) { // if somethings' selected
elements.filter('.' + value).show(); // show the ones we want
}
}).trigger('change');
});