jQuery选择器

jQuery选择器
https://www.w3school.com.cn/jquery/jquery_ref_selectors.asp
jquery 选择器 不包含某个属性值style
http://www.voidcn.com/article/p-psirzpxb-bua.html

1、查找标签:
$(table)
2、查找多个属性:
//选择不满足 条件1 attr1="a1" 或 条件2 attr2="a2"的元素
$('tbody td:not([attr1="a1"],[attr2="a2"])').css('color','orange');
$('tbody td[attr1!="a1"][attr2!="a2"]').css('color','black');
3、循环已找到的标签并进行移除:
$(".badReactionDescription").find("input[name='lvid'],input[name='cateGoryId']").each(function () {
        	//表单中的不良事件级别和不良事件类别只显示选中值标志
            var onlyShowFlag = true;
          	//当前只显示选中项
            if (onlyShowFlag) {
            	 if($(this).attr("checked")!='checked'){
           		 	$(this).parent().remove();
                }
            }
        });
4、去除标签样式:
$('选择器').css('css属性','');  
5、jq获取tr中td的colspan属性值(forEach遍历),并取其总和
//鱼骨图
        if ('Y' == flagfish) {
			$("#trc").show();
			var col = 0;
			$('tbody').find("tr").eq(0).find("td").each(function () {
				col += parseInt($(this).attr('colspan'));
	        });
			$("#yugutu").parent().attr('colspan',col-2);
			Renderfish();
		}
6、jq 获取包含某个属性值style
例如:table2excel不导出隐藏列(其他方法-隐藏的列,添加 noExl 样式,指定列不进行导出)
<tr>
	<th style="text-align: center;" data-value="1">次数</th>
	<th class="costHide" style="text-align: center; display: none;" data-value="1price">费用</th>
</tr>
var cols=$("thead tr").eq(1).find("th:visible").length+1; //查找style属性显示的列
$("thead tr").eq(1).find("th:hidden"); //查找style属性隐藏的列
var table=$("#reportTable").html();
			   	$("#reportTable2").html(table); 
			   	$("#reportTable2 th.costHide").remove(); //移除class属性值为costHide的列,最后导出
			   	$("#reportTable2").table2excel({
						exclude: ".noExl",
						name: "Excel Document Name",
						filename: title,
						exclude_img: true,
						exclude_links: true,
						exclude_inputs: true,
						cols:cols
				});
				parent.layer.closeAll();
JavaScript 如何去除字符串空格(trim、replace、replaceAll)
trim 去除字符串左右空格;
replace、replaceAll正则匹配法,替换空格;
replace(" ","");
replaceAll(" ","");
<!DOCTYPE html>
<body>
	<div class="fields">
		<table class="ui selectable celled table mini" id="tbs" >
			<thead>
				<tr>
					<th width="200px">是否报考
						<select class="mainnum dateWidth" style="width:3px;display:inline;" id="whetherAttend">
							<option value="1">已报名</option>
							<option value="2">未报名</option>
							<option value="0">全部</option>
						</select>
					</th>
				</tr>
			</thead>
		</table>
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function() {
		var whetherAttend = $("#whetherAttend option:selected").val();
	}
</script>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值