1、js如何判断checkbox是否选中html
$("input[type='checkbox']").is(':checked')
2、简单实现“记住我”jquery
一、htmlgit
<div class="checkbox"> <label> <input type="checkbox" value="记住我" id="remeber-me" >记住我 </label> </div>
二、本demo使用cookie来保存用户名和密码,其中cookie使用jquery-cookie.js插件,使用帮助请参考连接(https://github.com/carhartl/jquery-cookie)。github
三、js相关操做cookie
var name=$(".loginName").val(); var password=$(".loginpwd").val(); if($("input[type='checkbox']").is(":checked")==true){ //保存数据到cookie $.cookie('name', name); $.cookie('password', password); }else{ $.removeCookie('name'); $.removeCookie('password'); }