自動(dòng)調(diào)整為最大長度:
<select style="width:expression((this.offsetWidth>100)?'auto':'100')">
<option >hellohellohellohellohellohellohellohellohellohello</option>
</select>
鼠標(biāo)點(diǎn)時(shí)自動(dòng)變成最大長度,離開或選中時(shí)恢復(fù)原長度
<select name=s2 style="width:50px" onFocus="this.style.width='auto'"onblur="this.style.width='50px'" onChange="this.style.width ='50px'">
<option>1111111111111111111111111111</option>
<option>2222222222222222222</option>
</select>
鼠標(biāo)滑過時(shí)自動(dòng)變成最大長度,離開或選中時(shí)恢復(fù)原長度
<select name=s2 style="width:50px" onmouseover="this.style.width='auto'" onblur="this.style.width='50px'" onChange="this.style.width='50px'">
<option>1111111111111111111111111111</option>
<option>2222222222222222222</option>
</select>
選擇后在頁面的其它位置顯示選擇的項(xiàng)目
<div id=dsp></div>
<select name="select" size="1" onchange="dsp.innerText=this.options[this.selectedIndex].text">
<option value="1">test</option>
<option value="2" selected>test2</option>
</select>
鼠標(biāo)滑過時(shí)顯示當(dāng)前選擇的項(xiàng)目的值
<div id=div1 style="overflow:auto;height:expression(5*15);width:expression(document.all.s1.offsetWidth+18);">
<select name=s1 size=1 style="width:120" onmousemove="showTitle(this);"onmouseout="hideTitle(this);">
<option>aaaaaaaaaaaaaaaaaaaaaa1 </option>
<option >bbbbbbbbbbbbbbbbbbbbbbbbb1 </option>
<option>cccccccccccccccccccccccc1 </option>
<option>ddddddddddddddddddddddd1 </option>
<option>eeeeeeeeeeeeeeeeeeeeeee1 </option>
<option>fffffffffffffffffffffffffff1 </option>
</select>
</div>
<script>
// 定義Popup
var oP=window.createPopup();
oP.document.body.style.background="beige";
//popup 是否已顯示
var oPShow=0;
function showTitle(obj){
var h=event.offsetY;
var fontsize=(obj.style.fontSize==""?(obj.currentStyle.fontSize==""?"9":obj.currentStyle.fontSize):obj.style.fontSize);
fontsize=parseInt(fontsize)*1.6;
var l=parseInt(h/fontsize);
oP.document.body.innerText=obj.options[l].text;
len=obj.options[l].text.length*8;
oP.show(event.offsetX+20,event.offsetY+fontsize+5,len,fontsize,document.body);
oPShow=1;
}
function hideTitle(obj){
if(oPShow==1)oP.hide();
}
</script>
更多信息請(qǐng)查看IT技術(shù)專欄