2010-10-29 67 views
0

我试图将以下DOM生成的iframe放入页面的某个部分。特别是我希望它坐在一个div中,我有名字“地图”。现在它一直悬浮在页面底部,可能是因为它被放置在那里。有没有办法找到名为地图的div,并将其放置在该div标签之后?将iframe添加到HTML中的特定位置使用jquery

任何帮助,将不胜感激!下面是代码:

 function handle_geolocation_query(position) { 


     var image_url = "http://maps.google.com/?ie=UTF8&[email protected]" + position.coords.latitude + ',' + position.coords.longitude + 
         "&z=16&output=embed"; 

     jQuery("#map").remove(); 
     $(document.body).append(
      jQuery(document.createElement("iframe")).attr("src", image_url).attr('width','320').attr('height','320').attr('id','map') 
     ); 

    } 

回答

0
$('#maps') 
    .after('<iframe src="'+image_url+'" width="320" height="320" id="map"'); 

会发现与maps该ID的DIV和元素之后追加的iframe。我不确定你是否真的想要它在div或div内部(尽管我觉得它应该在里面)。

相关问题