爱程序网

图片选中出现边框效果

来源: 阅读:

图片选中出现边框效果:
当点击选中图片时,图片能够出现红色的边框效果。
代码实例如下:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="http://www.softwhy.com/" />
<title>图片选中出现边框效果</title>
<style type="text/css"> 
#mainboard img
{ 
  border:1px solid #cccccc; 
   width:88px; 
   height:31px; 
   cursor:pointer; 
} 
</style> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript"> 
$(function(){ 
   $("#mainboard img").bind("click",function(){ 
       $(this).css("border","1px solid red").siblings().css("border","1px solid #cccccc"); 
   }) 
}) 
</script> 
</head> 
<body> 
<div id="mainboard"> 
  <img src="1.gif" class="b" /> 
  <img src="2.gif" /> 
  <img src="3.gif" /> 
  <img src="4.gif" /> 
</div> 
</body> 
</html>

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=7861

更多内容可以参阅:http://www.softwhy.com/jquery/

 

关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助