Great! How may I assist you today?
<div id="content"><p>Here is a cool video. Check it out: http://www.youtube.com/watch?v=oHg5SJYRHA0</p></div>
我希望使用js(jquery)获取链接并将其替换为嵌入代码。
更新1:
这是我目前的js代码:
$("#content").each(function(){
var allContent = $(this).html();
//need regex to find all links with youtube in it, ovbiously it can't == youtube.com, but basically the link has to have youtube.com in it.
if ($("a",allContent).attr("href") == "youtube.com" ) {
// grab youtube video id
/* replace link with <div id="yt-video">
<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/429l13dS6kQ&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/429l13dS6kQ&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>
</div>
*/
}
});