使用Jquery设置href

时间:2014-06-24 18:59:18

标签: javascript jquery

我试图使用下面的Jquery语句设置一条消息。" Here"在消息中应该链接到href链接..

如何使用相同的Jquery stmt?

$('#message').html('Access Denied: .Click Here to login with your card.')

2 个答案:

答案 0 :(得分:1)

$('#message').html('Access Denied: .Click <a href="mylink.html">Here</a> to login with your card.')

jQuery将在插入时解析字符串中的html。

答案 1 :(得分:0)

尝试这样的事情:

$(document).ready(function(){
$("#test").click(function(){
var link = "<a href='www.google.cl'>Here</a>"    
$('#message').html('Access Denied: .Click '+link+' to login with your card.')
});
});

工作小提琴:http://jsfiddle.net/robertrozas/bG38U/