jquery触发a标签跳转事件示例代码
人气:0
1.写入<a>标签:
<a target="_blank" href="javascript:void(0)" onclick="checkValidate()">水觅微博</a>
2.加入JS:
<script type="text/javascript">
function checkValidate(){
if($("#signOut").text()){
window.location.href="<%=basePath%>/jsp/weibo/index.jsp";
}else{
window.location.href="<%=basePath%>index.jsp";
}
}
</script>
3.解释:
$("#signOut").text()为我所需要判断的对应ID的Html元素的值
<a target="_blank" href="javascript:void(0)" onclick="checkValidate()">水觅微博</a>
2.加入JS:
复制代码 代码如下:
<script type="text/javascript">
function checkValidate(){
if($("#signOut").text()){
window.location.href="<%=basePath%>/jsp/weibo/index.jsp";
}else{
window.location.href="<%=basePath%>index.jsp";
}
}
</script>
3.解释:
$("#signOut").text()为我所需要判断的对应ID的Html元素的值
加载全部内容