javascript - jQuery str.replace not working -


i need search string (video embed url) once page loads , replace & &. best guess code have tried seems have no effect:

(function ($, document, undefined) {     $(document).ready(function(){         var str = $( "iframe" ).attr( "src" );         str = str.replace(/&/g,"&");         $( "iframe" ).attr( "src",str );     }); })(jquery, document); 

there once iframe on page , looks this:

<iframe src='http://player.vimeo.com/video/72874423?title=0&byline=0&portrait=0;api=1' width='615' height='355' style='width:615px;height:355px;'></iframe> 

what doing wrong?

the problem once javascript manipulates dom, &amp; encoded html &. actual javascript replace & &amp; works fine.

see this fork of commenter's jsfiddle. when alert happens, string has &amp;, once it's written document, displays &


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -