我试图从第15个td列获取div并将div的宽度设置为300px。
我有表格摘要来识别表格。如何设定宽度?
<table summary="Copy and Design RFP">
....
...
/* column15*/
<td class="ms-vb2">
<div dir="">1/9/14 - 1st draft sent</div>
</td>
到目前为止我写了
$(document).ready(function () {
if (window.location.href.indexOf("dept/mkt/Lists/Request for Projects/Active Projects.aspx") > -1) {
$('table[summary="Copy and Design RFP"] tr td:nth-child(15)').each(function() {
var id = $(this).find('div'); // This is not working
});
}
});
答案 0 :(得分:2)
使用nth-child
选择器:
$('table[summary="Copy and Design RFP"] td:nth-child(15) div').css('width', '300px');
答案 1 :(得分:0)
我创建了这个解决方案:
<强> JS 强>
var i = 1;
$("table tr").children().each(function(){
if(i==15){
var div = $(this).find("div");
$(div).attr("style","height:300px;");
}
i++;
});