只要你有一台电脑或者手机,都能关注图老师为大家精心推荐的jQuery 全选效果实现代码,手机电脑控们准备好了吗?一起看过来吧!
【 tulaoshi.com - Web开发 】
多选效果如下图
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)代码如下:
代码如下:
script type="text/javascript"!--
$(document).ready(function() {
$("#selectall").click(selectAll);
});
function selectAll() {
var checked = $("#selectall").attr("checked");
$(".selectable").each(function() {
var subchecked = $(this).attr("checked");
if (subchecked != checked)
$(this).click();
});
}
// --/script
table id="detail-table" style="width: 100%; background: #F0F8FF;"
thead
tr
th input id="selectall" type="checkbox" //th
th style="text-align:center" style="text-align:center"Item Name/th
th style="width: 60px; text-align:center"UM/th
th style="width: 80px; text-align:center"Ordered Qty/th
th style="width: 80px; text-align:center"Received Qty/th
th style="width: 80px; text-align:center"Quantity/th
th style="width: 120px; text-align:center"Remark/th
/tr
/thead
?php
$i = 1;
foreach($this-details as $item) {
echo "trn";
echo "td width='6px'input type='Checkbox' id='item_id$i' name='item_id$i' class='selectable' value='" . $item["item_id"] . "' //tdn";
//item name
echo "td " . $item["item_name"] . "input type='hidden' id='item_id$i' name='item_id$i' value='" . $item["item_id"] . "' /input type='hidden' id='item_name$i' name='item_name$i' value='" . $item["item_name"] . "' //tdn";
//unit
echo "td" . $item["unit_name"] . "/tdn";
//Ordered Qty
echo "td style="text-align: right" style="text-align: right"" . $item["quantity"] . "/tdn";
//Received Qty
echo "td style="text-align: right" style="text-align: right"" . $item["received_qty"] . "/tdn";
//Quantity
echo "tdinput style='width: 99%; text-align: right' type='text' id='quantity$i' name='quantity$i' MaxLength='4' OnKeyPress='EnsureDecimal(this)'//tdn";
//Remark column
echo "tdinput style='width: 99%;' type='text' id='remark$i' name='remark$i' MaxLength='30'/td";
echo "/trn";
$i++;
}
?
/table
局部多选如下图
代码
代码如下:
script type="text/javascript"!--
function selectAllMenu(cmb) {
var checked = cmb.checked;
$(".selectable[model=" + cmb.model + "]").each(function() {
var subchecked = $(this).attr("checked");
if (subchecked != checked)
$(this).click();
});
}
// --/script
?php
if (isset($this-user)) {
echo "h3Privilege Setting For User " . $this-user ."/h3";
}
elseif (isset($this-role)) {
echo "h3Privilege Setting For Role " . $this-role . "/h3";
}
else {
echo "h3Privilege Setting/h3";
}
?
form id="form1" method="post" action="?php echo $this-baseUrl . '/admin/privilege/save'; ?"
center
table class="stripe" style="text-align: left" style="text-align: left" width="80%"
?php
$model_name = "";
foreach($this-privileges as $privilege) {
if ($model_name != $privilege['model_name']) {
$model_name = $privilege['model_name'];
echo "trn";
echo " td style='width:20px'input model='$model_name' class='selectall' type='checkbox' onclick='selectAllMenu(this);'//tdn";
echo " td colspan='2'b$model_name/b/tdn";
echo "/trn";
}
echo "trn";
echo " td/tdn";
echo " td style='width:20px'input model='$model_name' type='checkbox' class='selectable'//tdn";
echo " td" . $privilege['display_text'] . "/tdn";
echo "/trn";
}
?
/table
/center
div style="padding-top: 10px" style="padding-top: 10px"
?php
$button_panel = new ButtonPanel();
$button_panel-setButtonAlign("center");
$button_panel-addButton(array("text" = "Save", "type" = "submit"));
$button_panel-addButton(array("text" = "Reset", "type" = "reset"));
$button_panel-addButton(array("text" = "Back", "onclick" = "window.history.back();"));
$button_panel-render();
?
/div
/form
来源:http://www.tulaoshi.com/n/20160219/1611018.html
看过《jQuery 全选效果实现代码》的人还看了以下文章 更多>>