我的div不使用jQuery重定向 [英] My div is not redirecting using jQuery
本文介绍了我的div不使用jQuery重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从此处使用jQuery: http://ajax .googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
Using jQuery from here: http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
$(".myBox").click(function(){
window.location=$(this).attr("http://google.com");
}
上面的代码不起作用,有人可以帮我吗!
The above code doesn't work, can someone help me please!
推荐答案
上面发布的TurnItUp应该也可以正常工作,但是在这里,您可以使用JQuery方法:
What TurnItUp posted above should work as well but here you go, the JQuery approach:
$(".mybox").click(function(){
$(location).attr('href','http://www.google.com');
});
我还假定您将其包装在文档就绪事件"下,对吗?
I also assume that you're wrapping it under "document ready event", correct ?
真正应该是
$(function()
{
$(".mybox").click(function(){
$(location).attr('href','http://www.google.com');
});
});
这篇关于我的div不使用jQuery重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文