I want to get element that called the function and append embed Google map to target div. I'm trying with this code but not working
function myfunction(currentElement){
var $elemId = $(this).attr("id");
$( ".$elemId" ).append( "<iframe frameborder="0" scrolling="no" marginheight="0"
marginwidth="0" src="https://maps.google.ch/maps?f=q&source=s_q&hl=de&geocode=&q=Bern&aq=&
sll=46.813187,8.22421&sspn=3.379772,8.453979&
ie=UTF8&hq=&hnear=Bern&t=m&z=12&
ll=46.947922,7.444608&output=embed&iwloc=near"></iframe>");
}
<div class='Flexible-container'>
<a href="#" id="showmap0" name="showmap0" onclick="myfunction(this);">show</a>
<div class='showmap0'></div>
</div>
For Id we use #selectId
function myfunction(currentElement){
var $elemId = $(this).attr("id");
$( '#'+$elemId ).append( "<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.ch/maps?f=q&source=s_q&hl=de&geocode=&q=Bern&aq=& sll=46.813187,8.22421&sspn=3.379772,8.453979& ie=UTF8&hq=&hnear=Bern&t=m&z=12& ll=46.947922,7.444608&output=embed&iwloc=near"></iframe>" );
}
I hope this help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.