我尝试重新设置select option的样式,但是该选项的值不会传递给jQuery创建的新类。因此,我无法得到正确的结果。正确的结果是,当我单击美国时,它显示奥斯汀,而单击德国时显示柏林
这是代码,http://jsfiddle.net/xvDbv/1/
应该改为如下所示
text: $this.children('option','value').eq(i).text()?有人能帮助解决VALUE通行证的问题吗?
在广告中非常感谢
发布于 2012-09-26 10:34:59
这是因为在构建伪select时从未调用过countrySelectChanged函数。在函数中添加对它的调用:
$listItems.click(function(e) {
e.stopPropagation();
$styledSelect.text($(this).text()).removeClass('active');
$this.val($(this).attr('rel'));
$list.hide(); /* alert($this.val()); Uncomment this for demonstration! */
countrySelectChanged();
});发布于 2012-09-26 10:46:20
我在li中添加了on侦听器。
$('<li />', {
text: $this.children('option').eq(i).text(),
rel: $this.children('option').eq(i).val()
}).on("click", function(){
$(".hide").hide();
$("#" + $(this).text().toLowerCase() + "-select").show();
}).appendTo($list);jsFiddle
https://stackoverflow.com/questions/12593713
复制相似问题