Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通过Jquery获取表列_Javascript_Jquery_Html_Markup - Fatal编程技术网

Javascript 通过Jquery获取表列

Javascript 通过Jquery获取表列,javascript,jquery,html,markup,Javascript,Jquery,Html,Markup,我需要将此html表格的第二列设置为“粗体”: 如何使用JQuery 我尝试过这个,但不起作用: $("h3.ms-standardheader").children("td").text("<b>"+this.text()+"</b>") $(“h3.ms standardheader”).children(“td”).text(“+this.text()+”) 改用.html() $(".ms-standardheader").closest('tr').find

我需要将此html表格的第二列设置为“粗体”:

如何使用JQuery
我尝试过这个,但不起作用:

$("h3.ms-standardheader").children("td").text("<b>"+this.text()+"</b>")
$(“h3.ms standardheader”).children(“td”).text(“+this.text()+”)
改用
.html()

$(".ms-standardheader").closest('tr').find("td").html(function () {
    return "<b>" + $(this).text() + "</b>"
});
$(.ms standardheader”).closest('tr').find(“td”).html(函数(){
返回“+$(this).text()+”
});
此外,选择器不正确,您需要使用最近的,然后找到

或者,如果您不希望ms standardheader也获得
,您可以使用sibbines()

$(“.ms standardheader”).closest('td').Sleeps('td').html(函数(){
返回“+$(this).text()+”
});

改用
.html()

$(".ms-standardheader").closest('tr').find("td").html(function () {
    return "<b>" + $(this).text() + "</b>"
});
$(.ms standardheader”).closest('tr').find(“td”).html(函数(){
返回“+$(this).text()+”
});
此外,选择器不正确,您需要使用最近的,然后找到

或者,如果您不希望ms standardheader也获得
,您可以使用sibbines()

$(“.ms standardheader”).closest('td').Sleeps('td').html(函数(){
返回“+$(this).text()+”
});
您也可以使用css

看这里

您也可以使用css

看这里


你可以用这个。创建一个css类,并使用js添加这个类。思考更简单

css

.bold{
    font-weight: bold;
}
$('table td:nth-child(3)').addClass('bold');
js

.bold{
    font-weight: bold;
}
$('table td:nth-child(3)').addClass('bold');

您可以使用这个。创建一个css类,并使用js添加这个类。思考更简单

css

.bold{
    font-weight: bold;
}
$('table td:nth-child(3)').addClass('bold');
js

.bold{
    font-weight: bold;
}
$('table td:nth-child(3)').addClass('bold');

我会使用NTHCILD选择器,如果您想要任何其他粗体,您可以输入偶数或奇数 我希望这有帮助

$("tr td:nth-child(2)").css({"color":"red"});
$("tr td:nth-child(even)").css({"background":"grey"});

我会使用NTHCILD选择器,如果您想要任何其他粗体,您可以输入偶数或奇数 我希望这有帮助

$("tr td:nth-child(2)").css({"color":"red"});
$("tr td:nth-child(even)").css({"background":"grey"});

它仍然不起作用,我认为问题是到达元素。如果它仍然不起作用,我认为问题是到达元素。IE<9中的
:n子
的浏览器支持是有限的。不知道所有OP需要支持什么,但这可能是一个因素。使用表tr td:first child+td+td解决。请注意,IE<9中浏览器对
:n个child
的支持是有限的。不知道所有OP需要支持什么,但这可能是一个因素。使用表tr td:first child+td+td解决