jquery通过id和attr方法获取a标签的href属性的地址,并实现跳转:
<!DOCTYPE html>
<html>
<head>
<script src="/jquery/jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
window.open($("#baidu").attr("href"),'_self');
});
});
</script>
</head>
<body>
<p><a href="http://www.baidu.com" id="baidu">百度</a></p>
<button>跳转到百度</button>
</body>
</html>