2011-12-14 81 views
0

我想更改下面代码的区域Id的href更改区域Id的href

<map name="green" id="green"> 
    <area manual_cm_sp="prospect-_-ZarzamoraUITT-_-iwant" href="http://es.t-mobile.com/shop/phones/?action=ADDPROMOTIONALPACKAGE&amp;id=5E725E06-32E7-430E-BA16-0327719DC724&amp;quantity=1" coords="380,419,746,442" alt="Llévate sólo el teléfono HTC Radar 4G" shape="RECT" title="Llévate sólo el teléfono HTC Radar 4G" id="prospectZarzamoraUITTiwant"> 
    <area manual_cm_sp="prospect-_-ZarzamoraUITT-_-iwant" href="http://es.t-mobile.com/shop/phones/?action=ADDPROMOTIONALPACKAGE&amp;id=7BFCC0F4-DF24-4137-85BE-F679A6F0372F&amp;quantity=1" coords="380,446,746,469" alt="Llévatelo con servicio internacional" shape="RECT" title="Llévatelo con servicio internacional" id="Area2"> 
</map> 
+0

什么是你的问题?获取对元素的引用?访问它的`href`属性?这些都是简单的操作,每个jQuery教程都应该包含这些操作。查看[ID选择器](http://api.jquery.com/id-selector/)和[`.attr`](http://api.jquery.com/attr/)方法。阅读文档有助于。 – 2011-12-14 19:04:14

回答

0

如果你知道area的id要更改:

$("#Area2").attr('href','newurl.php'); 
+0

我想知道weathert我可以像div ID一样使用areaId。 – Noname 2011-12-14 19:09:35

0

如果你知道一个元素的ID,你可以选择它,然后用.attr()来访问它的属性:

$('#id-goes-here').attr('href', 'new-href-goes-here'); 

这同样可以在本地JavaScript来实现:

document.getElementById('id-goes-here').href = 'new-href-goes-here'; 

我建议您检查出的文档.attr()http://api.jquery.com/attr(嘿嘿,而你在那里,为什么不浏览四周,看看你能学到什么)