select option,鼠标移到哪个选向就给出相应的鼠标提示该怎么做!

作者&投稿:错侍 (若有异议请与网页底部的电邮联系)
如何让鼠标移到select中option上时产生事件~


1
2
3
4
5
6

当我鼠标移上select中的一个option时能不能获取当前option的值呢?那个onchange我知道,我想用onmouseove事件是不是可以做到?
如果不行,有哪个大大能告诉我怎么重写个select啊,从而能达到上述效果呢?
我想了很长时间都没想出来,希望有哪个大大解决下,那个希望在html上做。
问题补充:qinglangee 写道




function attachTest() {
$("#select").bind("mouseover", function(e){
if (e.target.id!= 'select') {
document.getElementById('test').innerHTML = e.target.value;
}
});
}



Something Here


One
Two
Three
Four






qinglangee 写道以下代码只在firefox chrome等浏览器中有效
因为ie6中没有onmouseover事件,所以用jquery绑定事件也是一样

所以还是用div来模仿select显示比较好





function showselectValue(e) {
if (e.target.id!= 'select') {
document.getElementById('test').innerHTML = e.target.value;
}
}

function attachTest() {
document.getElementById('select').addEventListener('mouseover',showselectValue,false);
}







Something Here


One
Two
Three
Four






好像没有下拉列表选项的onmouseover事件,你可以选择onchange事件

你可以看看这个网站,不知道是不是这个意思 http://www.hlib.cn/zhidao/show.asp?topicid=4664509

<style type="text/css">

#dhtmltooltip{
position: absolute;
left: -300px;
width: 150px;
border: 1px solid black;
padding: 2px;
background-color: lightyellow;
visibility: hidden;
z-index: 100;
/*Remove below line to remove shadow. Below line should always appear last within this CSS*/
filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
}

#dhtmlpointer{
position:absolute;
left: -300px;
z-index: 101;
visibility: hidden;
}

</style>
<script type="text/javascript">

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
function fSelhit()
{
var hitinfo=document.all.Sel.options[document.all.Sel.selectedIndex].text ;
if (ns6||ie)
{
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=hitinfo
enabletip=true
return false
}

}

document.onmousemove=positiontip

</script>
<select id=Sel onmouseover="fSelhit()" onMouseout="hideddrivetip()">
<option>saaaaaaaaa</option>
<option>bbbbbb</option>
<option>ddddd</option>

</select>
<div onMouseover="ddrivetip('Yahoo\'s Site', 250)";
onMouseout="hideddrivetip()">This is a DIV. This is a DIV.</div>


林口县18610755428: 如何让鼠标移到select中option上时产生事件 -
卫念抗感: <select size=3 > <option id="1">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option></select> 当我鼠标移上select中的一个option时能...

林口县18610755428: jquery如何移动select中option的位置? -
卫念抗感: 使用jquery的外部插入的函数,如下: <select id="sel"> <option>a</option> <option>b</option> <option>c</option> </select> <br /> <input type="button" id="btn" value="点击我" /><SCRIPT LANGUAGE="JavaScript"> $(document)....

林口县18610755428: jsp(HTNL) SELECT选择框鼠标滚动选项 -
卫念抗感: 鼠标滑动是浏览器为了方便用户带的 .如果想不要 你可以在 加个 onclick事件当选择完后然它失去焦点.<select name="yjsj" onchange="change()" style="width:272px;"> <option id="1" value="aa">aa</option> <option id="2" ...

林口县18610755428: 能不能让鼠标放到select上的时候,option就出来?
卫念抗感: select没有展开,关闭事件,要实现基本上是很困难的可以考虑用JS+HTML来模拟一个.

林口县18610755428: 如何让select的样式也漂亮起来 -
卫念抗感: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/...

林口县18610755428: select option是什么意思 -
卫念抗感: select option 网络 网页中的下拉框即; 选择选项; [例句]Select this option if you have deleted this file or uninstalled an application recently. 如果您已经删除了这个文件或最近卸载了某个应用程序,请选择此选项.

林口县18610755428: rhino4.0鼠标左键选中物体怎样设置才会不被随意移动? -
卫念抗感: 你这问题简单,打开软件进入设置项 option,在左面选择Mouse鼠标,勾选如图的选项即可 有关3D软件设计问题可以共同探讨

林口县18610755428: 如何实现select中Option的onmouseover事件? -
卫念抗感: 在select的option标签中加上一个title属性.title="值"这个是自带的效果,你试试看

林口县18610755428: div css下拉框样式参数设置 -
卫念抗感: <style type="text/css">.select * { margin: 0; padding: 0; }.select { border:1px solid #cccccc; float: left; display: inline; }.select div { border:1px solid #f9f9f9; float: left; }/* 子选择器,在FF等非IE浏览器中识别 */.select>div { width:120px; height: 17px; ...

林口县18610755428: select中怎样选中某个option -
卫念抗感: 有两种方法,一、在需要选中的那个option中添加一个属性 selected = "selected"; 二、通过js代码设置 $("#select").val("value");//value的值是你选择的那个option的那个值

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网