Reputation: 53806
Why is below function update()
not updating ? Is the structure of this fiddle correct ?
fiddle code :
HTML:
<body>
<div id="toupdate">
<script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6343621.js"></script>
</div>
</body>
JavaScript:
$(document).ready(function() {
update();
});
function update(){
$('#toupdate').remove();
alert('removed');
$('body').append('<div id="toupdate">
<script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6343621.js"></script>
</div>');
}
Upvotes: 1
Views: 78
Reputation: 227240
You can't have new lines in a JavaScript string like that. Also the </script>
maybe causing the JS to stop.
$('body').append('<div id="toupdate"><script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6343621.js"></scr'+'ipt></div>');
Upvotes: 7