首页 > 语言 > JavaScript > 正文

jquery触发a标签跳转事件示例代码

2024-05-06 14:37:31
字体:
来源:转载
供稿:网友
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元素的值
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选