日期:2014-05-16 浏览次数:20416 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> .a { position:absolute; background:#eee; opacity:.4; filter:alpha(opacity=40); color:red; font-weight:bold; cursor:pointer; text-align:center; } </style> </head> <body> <pre> coords x1 y1 x2 y2 x1 是 left y1 是 top x2 - x1 是 width y2 - y1 是 height </pre> <div id="test" style="position:relative;"> <img src="http://img.my.csdn.net/uploads/201206/08/1339142640_5754.jpg" border="0" usemap="#Map" /> </div> <map name="Map" id="map1"> <area shape="rect" coords="21,21,80,73" data-id="1638"> <area shape="rect" coords="79,23,158,72" data-id="1633"> </map> <script src="http://code.jquery.com/jquery-latest.js"></script> <script src="1.asp"></script> <script> //alert(json['1638']) $('#map1 area').each(function(){ var t = json[$(this).attr('data-id')]; if( t && t != 'none' ){ var tmp = this.coords.split(','); $('<div class="a">已定</div>').css({ left: tmp[0] + 'px', top: tmp[1] + 'px', width: tmp[2] - tmp[0] + 'px', height: tmp[3] - tmp[1] + 'px', lineHeight: tmp[3] - tmp[1] + 'px' }).attr('title', t).appendTo('#test') } }) </script> </body> </html>