如何将其转换为可点击链接?

时间:2013-02-23 21:17:08

标签: jquery hyperlink clickable

如何将其转换为可点击链接?

$('#subTitle').text('Link to join: '   location.href);

3 个答案:

答案 0 :(得分:1)

假设$('#subTitle')是超链接(锚标记)

$('#subTitle').attr('href', location.href);

答案 1 :(得分:0)

您可以形成<a>代码:

$('#subTitle').text('Link to join: <a href="' + location.href + '">LinkText</a>');

答案 2 :(得分:0)

使用.html()代替.text()并添加锚:<a>

$( '#subTitle' ).html( 
    'Link to join: <a href="' + location.href + '">' + location.href + '</a>' 
);