how to insert div directly in tag href area shape

久未见 提交于 2019-12-13 08:36:30

问题


I wish to know if it is possible to insert following divs

<div id="cal1"> [dopbsp id="1"  lang=it]</div>

<div id="cal2"> [dopbsp id="1"  lang=it]</div>

<div id="cal3"> [dopbsp id="1"  lang=it]</div>

directly in the tag href image map linked by different shape areas as following

<area shape="circle" coords="160,59,20" href="#">
<area shape="circle" coords="111,58,20" href="#">
<area shape="circle" coords="60,59,20"  href="#">

so that when I click on shape area, for example

<area shape="circle" coords="160,59,20" href="#">

then correspondent div, for example

<div id="cal1"> [dopbsp id="1"  lang=it]</div>

is loaded under the map image Ps: dopbsp id="1" ... is a calendar booking plugin of wordpress

Thanks


回答1:


You cannot. <area> cannot have any child elements. See the World-wide Web compendium working draft on the area tag or the Mozilla Developer Network description for more information.

The way to do this is to connect a given <area> with a given <div> via IDs and use JavaScript to show/hide the <div> when you click on an <area>. Along the lines of:

<area shape="circle" coords="160,59,20" href="#id-of-div-1">
<area shape="circle" coords="111,58,20" href="#id-of-div-2">
<area shape="circle" coords="60,59,20"  href="#id-of-div-3">

<div class="divs-to-show-hide">
 <div id="id-of-div-1">some content here</div>
 <div id="id-of-div-2">some content here</div>
 <div id="id-of-div-3">some content here</div>
</div>

jQuery

$('area').on('click',function(e) {
 e.preventDefault();
 $(this.href).show().siblings().hide();
});


来源:https://stackoverflow.com/questions/21183492/how-to-insert-div-directly-in-tag-href-area-shape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!