JS完成动态给图片加多边框的措施_javascript本领_脚本之家

本文实例讲述了JS实现动态给图片添加边框的方法。分享给大家供大家参考。具体如下:

复制代码 代码如下:

用JS实现图片轮播的问题,谢谢了
我又来问问题了,(自学JS没人请教也是尴尬,好像找个师傅啊),下面是问题
谢谢了
这是图片轮播代码,麻烦大家,在浏览器打开看下,这样能说清楚问题

下面的JS代码设置图片的边框为2个像素,即border=2

<html>
<head>
<title>响应鼠标自动选中文本框内容</title>
</head>
www.hj8828.com,<body>
<input id=”a” type=”text” value=”请输入搜索词”
onmouseover=”selectInputContent(this.id)”/>
<script type=”text/javascript”>
function selectInputContent(n){
  obj =document.getElementById(n);
  obj.focus();
  obj.select();
}
</script>
</body>
</html>

<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title></title><style type="text/css">*{margin:0; padding:0;}li{list-style:none; background:#f60; float:left; margin-right:10px; border-radius:8px; padding:2px 6px; cursor:pointer; text-align:center;}ul{width:140px; position:absolute; bottom:20px; right:20px;}.main{width:720px; height:450px; margin:0 auto; position:relative; left:0; top:100px; border:5px green solid;}.abc{width:720px; height:106px; margin:auto; margin-top:120px; background:#ccc; text-align:center;}.abc img{margin-right:10px; width:144px; height:90px; margin-top:8px;}</style></head><body><div > <img src="1.jpg" /> <ul> <li onmousemove="showA">1</li> <li onmousemove="showA">2</li> <li onmousemove="showA">3</li> <li onmousemove="showA">4</li> </ul></div><div > <img src="1.jpg" onmousemove="showB"/> <img src="2.jpg" onmousemove="showB"/> <img src="3.jpg" onmousemove="showB"/> <img src="4.jpg" onmousemove="showB"/></div><script type="text/javascript"> var gh=1; var mc=1; var tup=['http://a1.qpic.cn/psb?/V11aE2wE1DtywZ/I93pSorEWp54MpVhMNDEuPoY6sWU2y4sel7zcxygX0U!/b/dAMAAAAAAAAA&bo=0ALCAdACwgEBCS4!&rf=viewer_4', 'http://a2.qpic.cn/psb?/V11aE2wE1DtywZ/gYhbpYS80HxerKihb7FP8Xz6oBPopJd4Dv.Or6VNIJM!/b/dFgAAAAAAAAA&bo=0ALCAdACwgEBACc!&rf=viewer_4', 'http://a2.qpic.cn/psb?/V11aE2wE1DtywZ/kC2U6ySDDMDiJi7Dmk5TtdH7S609Ny4mhTFEO96rNjg!/b/dGQAAAAAAAAA&bo=0ALCAdACwgEBACc!&rf=viewer_4', 'http://a1.qpic.cn/psb?/V11aE2wE1DtywZ/vC9QsPEduvx6GCOIpq80bXh0t3oUAIzT2smAfm*lrwY!/b/dB4AAAAAAAAA&bo=0ALCAdACwgEBACc!&rf=viewer_4']; document.getElementById('dianji1').style.backgroundColor='black'; document.getElementById('dianji1').style.color='white'; document.getElementById.style.border='3px #f60 solid'; function showA{ var dianjigh=document.getElementById('dianji'+gh); var dianjia=document.getElementById('dianji'+a); dianjigh.style.backgroundColor='#f60'; dianjigh.style.color='black'; document.getElementById.style.border='none'; dianjia.style.backgroundColor='black'; dianjia.style.color='white'; document.getElementById.src=tup[a-1]; document.getElementById.style.border='3px #f60 solid'; gh=a; } function showB{ var dianjimc=document.getElementById('dianji'+mc); var dianjic=document.getElementById('dianji'+c); dianjimc.style.backgroundColor='#f60'; dianjimc.style.color='black'; document.getElementById.style.border='none'; dianjic.style.backgroundColor='black'; dianjic.style.color='white'; document.getElementById.src=tup[c-1]; document.getElementById.style.border='3px #f60 solid'; mc=c; }</script></body></html>