我有一些由 Sigma 动态创建的代码,如下所示:
<div id="myGrid1_headDiv" class="gt-head-div">
<div class="gt-head-wrap">
<table id="myGrid1_headTable" class="gt-head-table">
<tbody>
<tr class="gt-hd-row">
<td class="gt-col-mygrid1-uid">
<div class="gt-inner gt-inner-left" unselectable="on" title="#">
<span>#</span>
<div class="gt-hd-tool"><span class="gt-hd-icon"></span>
<span class="gt-hd-button"></span>
<span class="gt-hd-split" style="cursor: col-resize; "></span></div></div></td>
<td class="gt-col-mygrid1-p_deldate">
<div class="gt-inner gt-inner-left" unselectable="on" title="Planned Delivery Date">
<span>Planned Delivery Date</span>
<div class="gt-hd-tool"><span class="gt-hd-icon"></span>
<span class="gt-hd-button"></span>
<span class="gt-hd-split" style="cursor: col-resize; "></span></div></div></td>
我正在尝试针对未分类的跨度(# 和计划的交付日期),以便为它们设置样式:
$("div.gt-inner:first-child span")
{
$(this).addClass("celltitle");
};
但它没有效果。如您所见,它周围还有其他我不想触及的跨度。我究竟做错了什么?
===== 使用 Sigma Grid 的其他人的最终答案:
感谢@minitech 的指点,答案是添加到 Sigma Grid 的 gridOption 中:
onComplete:function(grid){
$('div.gt-inner > span').addClass('celltitle'); //add cell title after grid load
}