在js中给a标签写划过的样式怎么写?

JavaScript07

在js中给a标签写划过的样式怎么写?,第1张

定义Id<a id="abc" href="">aaaaa</a>js 代码 赋css样式document.getElementById("abc").className = "cssysb"document.getElementById("abc").className = "cssysb2"在css定义.cssysb{font-size:12px}.cssysb2{font-size:14px}

首先随便找一个地方新建一个div 并且隐藏。例如

<div id='showTip' style="background-color: white width:200pxheight:200pxposition: absolutedisplay: none">

</div>

然后在链接那边写个onmouseover 属性加个触发方法 如showDiv()具体方法如下

function showDiv(e){

$("#showTip").html("这里可以写一些html的内容,如图片文字")

$("#showTip").css("top",e.clientY)//这里可以根据情况适当调整

$("#showTip").css("left",e.clientX)

$("#showTip").show()

}

还要在链接那边加上 onmouseout属性触发方法如下:

function hideDiv(){

$("#showTip").hide()

}

以上需要引入jquery支持