2011-07-03 24 views

回答

1

或者我假設你想在單擊後替換一個標籤? 注意:我用div替換'video'標籤,只是爲了讓您更容易地看到更改。

$(document).ready(function(){ 
    $('.toVideo').live('click', function(e){ 
     $(this).replaceWith('<div src="' + $(this).attr('href') + '">new video</div>'); 
     e.preventDefault(); 
    }) 
}) 

這裏是例子: http://jsfiddle.net/a9xHS/5/

或者,如果您要更換所有的標籤,也許你可以:

$(document).ready(function(){ 
    $('.toVideo').each(function(){ 
     $(this).replaceWith('<div src="' + $(this).attr('href') + '">' + $(this).attr('href') + '</div>'); 
    }) 
}) 

http://jsfiddle.net/A9R3L/1/

+0

爲什麼downvote我的回答? –

+0

我不知道,但有人低估了所有的答案,包括我的 –