【发布时间】:2012-05-07 16:59:44
【问题描述】:
我有下面的 HTML 代码
<a href="http://www.google.com">Google</a>
当我点击链接时,我希望我的字符串包含下面的完整 HTML 代码
<a href="http://www.google.com">Google</a>
我尝试使用此方法,但我只能获取文本“Google”,无法获取锚代码。
$('#frame').contents().find('body').on("click", "a", function () {
var string = $(this).html();
alert(string);
});
当我需要 <a href="http://www.google.com">Google</a> 时,仅提醒 Google。
【问题讨论】:
标签: javascript jquery html innerhtml outerhtml