newElement
variable is missing there.
You should change
var newImage = "<embed scr="Image" />";
to
var newImage = "<embed scr=" + Image + " />";
var newElement = $(newImage);
and then should work
$('embed#GetWeatherIcon').remove();
parent.append(newElement);
Changing of src attribute is not working by this question
$('embed#GetWeatherIcon').attr('src', Image); // NOT WORKING
UPDATE:
I try your latest code and I find a problem. You made a mistake in src
attribute name, you wrote scr
and than it could not work. You also have an mistake in var imagename = Forcast[0]['icon']+".svg)";
, there is probably wrong closing bracket.
Here is my working code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<meta name="generator" content="HTML hackers, wwww.htmlhackers.com">
<title>Embed object change</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<style>
#GetWeatherIcon {
height:150px; width:150px; margin:30px 0 0 35px; padding:0; border:0; position:absolute;
}
</style>
</head>
<body>
<script>
$(document).ready(function() {
$('#change_btn').click(function() {
var imageurl = "http://upload.wikimedia.org/wikipedia/commons/e/e8/";
var imagename = "Svg_example3.svg";
var WeatherIcon = imageurl+imagename;
var parent = $('embed#GetWeatherIcon').parent();
var newImage = "<embed id=\"GetWeatherIcon\" src=\"" + WeatherIcon + "\" type=\"image/svg+xml\"/>";
var newElement = $(newImage);
$('embed#GetWeatherIcon').remove();
parent.append(newElement);
});
});
</script>
<p id="change_btn">Change</p>
<div>
<embed id="GetWeatherIcon" src="http://upload.wikimedia.org/wikipedia/commons/c/c9/Svg_example4.svg" type="image/svg+xml" />
</div>
</body>
</html>