Reputation: 9580
There are many answers on SO that show how to set an img src with .attr in jQuery. For some reason this is not working.
<img id="imgMap" style="position:absolute;bottom:7px;right:7px;width:250px;height:250px;" />
<script>
$(function () {
$("#imgMap").attr( 'src', 'http://maps.googleapis.com/maps/api/staticmap?center=41.886456,-87.62325&zoom=14&size=250x250&sensor=false&markers=color:blue%7Clabel:S%7C41.886456,-87.62325');
});
</script>
But the exact same url put inline in the HTML works fine
<img id="imgMap2" runat="server" src="http://maps.googleapis.com/maps/api/staticmap?center=41.886456,-87.62325&zoom=14&size=250x250&sensor=false&markers=color:blue%7Clabel:S%7C41.886456,-87.62325" style="position:absolute;bottom:7px;right:7px;width:250px;height:250px;" />
Upvotes: 1
Views: 240
Reputation: 13151
your code works fine for me, here is the link: jquery set attribute value
Upvotes: 0