java 动态生成checkbox_web前端 ajax加载动态生成复选框demo

1

body {

font-family: Arial, Helvetica, sans-serif;

font-size: 12px;

margin: 0;

}

#main {

height: 1800px;

padding-top: 90px;

text-align: center;

}

#fullbg {

background-color: gray;

left: 0;

opacity: 0.5;

position: absolute;

top: 0;

z-index: 3;

filter: alpha(opacity=50);

-moz-opacity: 0.5;

-khtml-opacity: 0.5;

}

#dialog {

background-color: #fff;

border: 5px solid rgba(0, 0, 0, 0.4);

height: 400px;

left: 50%;

margin: -200px 0 0 -200px;

padding: 1px;

position: fixed !important;

/* 浮动对话框 */

position: absolute;

top: 50%;

width: 400px;

z-index: 5;

border-radius: 5px;

display: none;

}

#dialog p {

margin: 0 0 12px;

height: 24px;

line-height: 24px;

background: #CCCCCC;

}

#dialog p.close {

text-align: right;

padding-right: 10px;

}

#dialog p.close a {

color: #fff;

text-decoration: none;

}

//显示灰色 jQuery 遮罩层

function showBg() {

var bh = $("body").height();

var bw = $("body").width();

$("#fullbg").css({

height: bh,

width: bw,

display: "block"

});

$("#dialog").show();

$.post("${ctx}/shwindow/",function (data) {

$.each(data, function (i, item) {

$("#CityObjectcb").append(

""

+""+

"item.cityName"+

"");

});

})

}

//关闭灰色 jQuery 遮罩

function closeBg() {

$("#fullbg,#dialog").hide();

}

function selectAll(){

if ($("#SelectAll").attr("checked")) {

$(":checkbox").attr("checked", true);

} else {

$(":checkbox").attr("checked", false);

}

}

$(function () {

//1,全选

$("#checkedAll").click(function () {

$("[name=items]:checkbox").attr('checked', true);

});

//2,全不选

$("#checkedNo").click(function () {

$("[name=items]:checkbox").attr('checked', false);

});

//3,反选

$("#checkedRev").click(function () {

$("[name=items]:checkbox").each(function () {

//$(this).attr('checked', !$(this).attr('checked')); //方式一

this.checked = !this.checked; //方式二

});

});

//5,提交选中的值

$("#send").click(function () {

var str = "选中的项是:\n\r";

$("[name=items]:checkbox:checked").each(function () {

str += $(this).val() + '\n\r';

});

alert(str);

});

});

关闭

选择城市:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值