根据复选框javascript显示和隐藏列 [英] Show and hide columns based on checkbox javascript
本文介绍了根据复选框javascript显示和隐藏列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好我想隐藏和显示gridview中的列基于复选框我做了一半的工作但我面临问题,我使用javascript和所有var值可以隐藏或显示良好,但当我使用数值int或者其他这个不起作用总列的问题taht有数值我认为var声明是问题some1help
我尝试过:
< script type =text / javascript>
$(function(){
$([id * = chkCountry])。click(function(){
var isChecked = $(this).is(:checked) );
var th = $([id * = GridView1] th:contains('Country'));
th.css(display,isChecked?:none) ;
$([id * = GridView1] tr)。each(function(){
$(this).find(td)。eq(th.index())。css (display,isChecked?:none);
});
});
});
$(function(){
$([id * = Name])。click(function(){
var isChecked = $(this).is(:checked) );
var th = $([id * = GridView1] th:contains('Name'));
th.css(display,isChecked?:none) ;
$([id * = GridView1] tr)。each(function(){
$(this).find(td)。eq(th.index())。css (display,isChecked?:none);
});
});
});
$(function(){
$([id * = chktotal])。click(function(){
var isChecked = $(this).is( :checked);
var th = $([id * = GridView1] th:contains('Total'));
th.css(display,isChecked?: none);
$([id * = GridView1] tr)。each(function(){
$(this).find(td)。eq(th.index( ))。css(display,isChecked?:none);
});
});
});
解决方案
(function(){
([id * = chkCountry])。click(function(){
var isChecked =
(this).is(:checked);
var th =
hello i want to hide and show columns in gridview based on checkbox i done half the job but i face problem, i used javascript and the all var value can hide or show good but when i use number value int or sth else this doesn't work teh problem with total column taht has number value i think the var declaration is the problem some1help
What I have tried:
<script type="text/javascript"> $(function () { $("[id*=chkCountry]").click(function () { var isChecked = $(this).is(":checked"); var th = $("[id*=GridView1] th:contains('Country')"); th.css("display", isChecked ? "" : "none"); $("[id*=GridView1] tr").each(function () { $(this).find("td").eq(th.index()).css("display", isChecked ? "" : "none"); }); }); }); $(function () { $("[id*=Name]").click(function () { var isChecked = $(this).is(":checked"); var th = $("[id*=GridView1] th:contains('Name')"); th.css("display", isChecked ? "" : "none"); $("[id*=GridView1] tr").each(function () { $(this).find("td").eq(th.index()).css("display", isChecked ? "" : "none"); }); }); }); $(function () { $("[id*=chktotal]").click(function () { var isChecked = $(this).is(":checked"); var th = $("[id*=GridView1] th:contains('Total')"); th.css("display", isChecked ? "" : "none"); $("[id*=GridView1] tr").each(function () { $(this).find("td").eq(th.index()).css("display", isChecked ? "" : "none"); }); }); });
解决方案
(function () {
("[id*=chkCountry]").click(function () { var isChecked =
(this).is(":checked"); var th =
这篇关于根据复选框javascript显示和隐藏列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文