如何动态为map添加area

whuzjf1985 2011-03-07 10:04:31
前端代码


<img id="Image1" class="map" src="upload/ProjectImages/1.jpg" width="1000" border="0"
usemap="#usa" />
<map name="usa" id="map1">

</map>


后端希望通过一个事件在图片上相应的地点添加一个红点




addEvent(container, 'click', function(ev) {
if (document.getElementById('txtCursorPoints') != null) {
var cursorPos = getMousePoint(ev);

$("#map1").append("<p>here</p>");
$("#map1").append("<area shape='circle' coords='296,388,9'/>"); var CursorPointsValue = document.getElementById('txtCursorPoints').value;
if (CursorPointsValue == "")
document.getElementById('txtCursorPoints').value = cursorPos.x + "," + cursorPos.y;
else {
document.getElementById('txtCursorPoints').value = CursorPointsValue + "," + cursorPos.x + "," + cursorPos.y;
}
}
});


但是发现根本没有添加红点 应该怎么做有哪位达人帮忙下~谢了。
...全文
192 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
whuzjf1985 2011-03-07
  • 打赏
  • 举报
回复
是啊 如何为area加上颜色,这个确实是一个头痛的问题 有没有人知道啊?
xiaoheixiaobai 2011-03-07
  • 打赏
  • 举报
回复

我知道怎么添加area,
var obj=document.getElementById("map1");
obj.innerHTML="<area shape='circle' coords='180,139,14' href ='venus.html' alt='Venus' />";

至于红点,弄不上去,没有颜色属性,怎么加上的呢?
whuzjf1985 2011-03-07
  • 打赏
  • 举报
回复
有没有人知道啊,非常急在线等。谢谢了~
whuzjf1985 2011-03-07
  • 打赏
  • 举报
回复
哪位大哥帮帮忙啊~
whuzjf1985 2011-03-07
  • 打赏
  • 举报
回复
$("#map1").append("<area shape='circle' coords='296,388,9'/>");

好像没效果

87,899

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧