I have a plain string:
var text = '<p>hello</p> <iframe src="http://whatever.com/1"></iframe><iframe src="http://notsosure.com"></iframe><iframe src="http://whatever.com/2"></iframe><p>goodby</p>'
I need to remove each iframe from the string starting with src=http://whatever.com
and replace them with a link pointing to the same url.
I thought I could do something like this with jQuery:
$text = $(text)
$text
.find("iframe[src^='http://whatever.com']")
.replaceWith('<a href="' + $( this ).attr('src') + '"> Click Here</a>')
But this doesn't work as it return the replaced string and it doesn't modify my original $text object.