0
我在獲取.wrap和.wrapAll方法在我的圖像映射上工作時遇到了一些困難。我假設這是因爲地圖不像圖像或輸入標籤那樣自我關閉。包裝圖像映射<div></div>
HTML:
<img class="img_class" id="bottle_map" src="../images/bottle.jpg" usemap="#bottle_map">
<map name="bottle_map">
<area shape="rect" alt="" coords="3,6,258,31" href="1" title="Saranac Legacy IPA">
<area shape="rect" alt="" coords="279,5,336,32" href="2" title="four generations">
<area shape="rect" alt="" coords="2,37,425,64" href="2" title="four generations">
<area shape="rect" alt="" coords="1,69,386,95" href="2" title="four generations">
<area shape="rect" alt="" coords="243,121,444,142" href="3" title="Matt Brewing Company">
<area shape="rect" alt="" coords="4,143,186,163" href="3" title="Matt Brewing Company">
<area shape="rect" alt="" coords="194,144,400,163" href="4" title="Our (great) grandfather">
<area shape="rect" alt="" coords="3,163,252,187" href="4" title="Our (great) grandfather">
<area shape="rect" alt="" coords="295,166,419,185" href="5" title="it's still family">
<area shape="rect" alt="" coords="3,189,363,209" href="5" title="it's still family">
</map>
JS/jQuery的:
$.fn.setupV2 = function(map) {
map_ref = "map[attribute='"+ map + "']";
img_ref = "img[usemap='\\#" + map + "']";
$(map_ref).wrapAll('<div class="mapContainer"></div>');
};
基本上我想要的圖像和圖像映射包裝成一個div在一起,這樣我就可以插入一個帆布和CSS樣式。有沒有辦法在注入HTML或在HTML中完成之前做到這一點?
哦,哇,非常感謝!我之前設置了非常相似的東西,但沒有運氣。我一定錯過了這個逗號,當它不可避免地不起作用時,它會引起恐慌 – Turk