<!--[if lt IE 9]>
<script type="text/javascript">
$(function(){
var el;
$("select")
.each(function() {
el = $(this);
el.data("origWidth", el.outerWidth()) // IE 8 can haz padding
})
.mouseenter(function(){
$(this).css("width", "auto");
})
.bind("blur change", function(){
el = $(this);
el.css("width", el.data("origWidth"));
});
});
</script>
<![endif]-->
另外在select 外层标签加上
[color=red]<div style="width:150px;overflow:hidden;">[/color]
<select style="width:150px;">
</select>
</div>
另外增加 select 选项的字数大于一个数字再加auto
$("select").each(function(){
var $select = $(this);
$select.data("orig", $select.outerWidth());
$select.find("option").each(function(){
if($(this).text().length > 30){
$select.data("orig",true);
return false;
}
});
});
<script type="text/javascript">
$(function(){
var el;
$("select")
.each(function() {
el = $(this);
el.data("origWidth", el.outerWidth()) // IE 8 can haz padding
})
.mouseenter(function(){
$(this).css("width", "auto");
})
.bind("blur change", function(){
el = $(this);
el.css("width", el.data("origWidth"));
});
});
</script>
<![endif]-->
另外在select 外层标签加上
[color=red]<div style="width:150px;overflow:hidden;">[/color]
<select style="width:150px;">
</select>
</div>
另外增加 select 选项的字数大于一个数字再加auto
$("select").each(function(){
var $select = $(this);
$select.data("orig", $select.outerWidth());
$select.find("option").each(function(){
if($(this).text().length > 30){
$select.data("orig",true);
return false;
}
});
});