jQuery判断是否选中
1.判断check是否选中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>判断check是否被选中</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<style type="text/css">
*{margin:0; padding: 0}
body{font:14px/1.4 "Microsoft Yahei",Arial,Helvetica,sans-serif;background-color: #fff;color:#333;max-width: 640px;margin: 0 auto;}
a{ text-decoration: none; color: #333 }
/*btn*/
.public_btn_s {padding: 10px 0; margin: 0 10px;}
.public_btn_s a { display: block; height: 34px; line-height: 34px; text-align: center; font-size: 18px; background-color: #31b6e7; color: #fff; border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; }
</style>
</head>
<body>
<div class="public_agreement">
<input type="checkbox" id="agreeInput" value="on">同意<a href="javascript:;" >个人隐私协议</a>
</div>
<div class="public_btn_s">
<a href="javascript:;" class="J_ajax_submit_btn">点击查看</a>
</div> <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
//按钮点击
$('.J_ajax_submit_btn').on('click',function(){
if($('#agreeInput').length){
if(!($('#agreeInput').is(':checked'))){
alert('您未同意个人隐私协议');
return false;
}else{
var url = 'http://www.baidu.com';
window.location.href=url;
}
}
});
})
</script> </body>
</html>

2.判断div是否被选中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>判断div是否被选中</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<style type="text/css">
*{margin:0; padding: 0}
body{font:14px/1.4 "Microsoft Yahei",Arial,Helvetica,sans-serif;background-color: #fff;color:#333;max-width: 640px;margin: 0 auto;}
a{ text-decoration: none; color: #333 }
/*选项卡*/
.form_tab{ overflow: hidden; background-color: #fffdf0; margin:5px 10px; border:1px solid #f9a268; border-radius: 5px;}
.ft_top{ overflow: hidden; height: 37px;line-height: 36px;}
.ft_top a{float: left; width: 50%; box-sizing: border-box; border-right:1px solid #f9a268; text-align: center; background-color: #ffedda; border-bottom:1px solid #f9a268;}
.ft_top a:last-child{ border-right:0}
.ft_top a:hover,.ft_top a.current{ background-color: #fffdf0; border-top:2px solid #db2121; color: #db2121;}
.ft_top a.current{ border-bottom:0}
.ft_con{overflow: hidden;padding:20px 10px ;}
.ft_con a{ height: 25px; line-height: 25px; padding:0 10px; border:1px solid #f9a268; background-color: #ffddbb;float:left; margin:0 5px; border-radius: 3px;}
.ft_con a.current{ color: #db2121; border-color: #db2121;} /*btn*/
.public_btn_s {padding: 10px 0; margin: 0 10px;}
.public_btn_s a { display: block; height: 34px; line-height: 34px; text-align: center; font-size: 18px; background-color: #31b6e7; color: #fff; border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; } </style>
</head>
<body>
<div class="form_tab">
<div class=" ft_top" id="tabMenu">
<a href="javascript:;" class="current">转盘法(排盘法)</a>
<a href="javascript:;">飞盘法(排盘法)</a>
</div>
<div class="ft_con "id="tabCon">
<a href="javascript:;">置润法</a>
<a href="javascript:;">拆补法</a>
<a href="javascript:;">茅山道人法</a>
</div>
</div>
<div class="public_btn_s">
<a href="javascript:;" class="J_ajax_submit_btn">点击查看</a>
</div> <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#tabMenu a").on('click',function () {
$(this).addClass('current').siblings().removeClass('current');
});
$('#tabCon a').on('click',function () {
$(this).addClass('current').siblings().removeClass('current');
});
//按钮点击
$('.J_ajax_submit_btn').on('click',function(){
if($('#tabCon a').length){
if(!($('#tabCon a').is('.current'))){
alert('您未选择排盘方法');
return false;
}else{
var url = 'http://www.baidu.com';
window.location.href=url;
}
}
});
})
</script> </body>
</html>
效果图:

jQuery判断是否选中的更多相关文章
- JQuery判断checkbox选中,jquery获取选中的checkbox
选中的radio $('input[name="radInvoiceType"]:checked').val(); 这样能获得 $('input[name="radInv ...
- 复选框、单选框 jquery判断是否选中Demo
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="eachcheckbox.a ...
- Jquery判断checkbox选中状态
jQuery v3.3.1 <input type="checkbox" id="ch"> 判断 $('#ch').is(':checked'); ...
- jquery判断input选中事件
需求是默认第一个是选中状态,点第二个选中,第一个取消然后点支付时,跳转新页面 $(function(){ $(".nl_zhifutj a").click(function(){ ...
- jquery判断复选框checkbox是否被选中
jquery判断复选框checkbox是否被选中 使用is方法 //如果选中返回true //如果未选中返回false .is(':checked');
- JQuery判断radio是否选中,获取选中值
本文摘自:http://www.cnblogs.com/xcj1989/archive/2011/06/29/JQUERY_RADIO.html /*----------------------- ...
- jquery判断复选框是否选中
jquery判断复选框是否被选中 $(function(){ $(document).on("click", ".checkbox",function(){ v ...
- jQuery 判断checkbox是否被选中 4种方法
下午写JS验证,有一个需求需要判断 checkbox是否被选择,查阅相关资料后,总结以下4种方法,分享给大家. <!DOCTYPE html> <html lang="en ...
- jquery判断按钮是否被选中了
<script type="text/javascript"> function genjin_view2(elm){ if($(elm).attr("che ...
随机推荐
- 正则表达式在java程序中的使用
package com.boco; import java.util.ArrayList;import java.util.List;import java.util.regex.Matcher;im ...
- java web 读取配置文件两种方法
package com.tsinghua.getDataBaseConn; import java.io.IOException;import java.io.InputStream;import j ...
- Mac 通过gem安装CocoaPods及Pod的使用
注:根据http://www.jianshu.com/p/6e5c0f78200a的文章做了部分修改 一.什么是CocoaPods CocoaPods是iOS项目的依赖管理工具,该项目源码在Githu ...
- sudo问题汇总
1. 注释Defaults requiretty Defaults requiretty修改为 #Defaults requiretty, 表示不需要控制终端. 否则会出现sudo: sorry, y ...
- 一个新手后端需要了解的前端核心知识点之position(一)
以下内容是基于观看慕课网视频教程总结的知识点,边打代码边总结,符合自己的思维习惯.不是针对新手入门 我做程序的初衷是想做一个网站出来.HTML语言当然重要啊,缺什么就百度什么,很浪费时间,还是好好的打 ...
- linux openjdk环境变量配置
下载openjdk : https://jdk.java.net/ tar -xvf ... nano ~/.bashrc export JAVA_HOME=... export PATH=$JAVA ...
- Mybatis:传入参数方式以及#{}与${}的区别
一.在MyBatis的select.insert.update.delete这些元素中都提到了parameterType这个属性.MyBatis现在可以使用的parameterType有基本数据类型和 ...
- configparser模块读写ini配置文件
在自动化测试过程中,为了提高脚本的可读性和降低维护成本,将一些通用信息写入配置文件,将重复使用的方法写成公共模块进行封装,使用时候直接调用即可. 这篇博客,介绍下python中利用configpars ...
- NodeJS下的阿里云企业邮箱邮件发送问题
还没有到11点,再顺带发一个上次碰到NodeJS的邮箱插件nodeMailer不支持阿里云邮件问题. 网上很多资料都默认使用QQ之类的邮箱,因为nodeMailer默认添加了QQ之类的SMTP地址,但 ...
- UVa 1220 Party at Hali-Bula (树形DP,最大独立集)
题意:公司有 n 个人形成一个树形结构,除了老板都有唯一的一个直系上司,要求选尽量多的人,但不能同时选一人上和他的直系上司,问最多能选多少人,并且是不是唯一的方案. 析:这个题几乎就是树的最大的独立集 ...