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>