以下是網格中我的Headers
的代碼。我想遍歷類ui-grid-header-cell
中的div
類ui-grid-cell-contents
,以獲取所有列標題&將其保存在Array對象中。Jquery - 在類中獲取DIV文本
<div class="ui-grid-header-cell clearfix ng-scope ng-isolate-scope ui-grid-coluiGrid-002">
<div class="ng-scope sortable">
<div class="ui-grid-vertical-bar"> </div>
<div class="ui-grid-cell-contents ng-binding" col-index="renderIndex">
Code <span ui-grid-visible="col.sort.direction" ng-class="{ 'ui-grid-icon-up-dir': col.sort.direction == asc, 'ui-grid-icon-down-dir': col.sort.direction == desc, 'ui-grid-icon-blank': !col.sort.direction }" class="ui-grid-icon-up-dir"> </span>
</div>
<div class="ui-grid-column-menu-button ng-scope" ng-if="grid.options.enableColumnMenus && !col.isRowHeader && col.colDef.enableColumnMenu !== false" ng-click="toggleMenu($event)"><i class="ui-grid-icon-angle-down"> </i></div>
</div>
</div>
<div class="ui-grid-header-cell clearfix ng-scope ng-isolate-scope ui-grid-coluiGrid-002">
<div class="ng-scope sortable">
<div class="ui-grid-vertical-bar"> </div>
<div class="ui-grid-cell-contents ng-binding" col-index="renderIndex">
EMPLOYEE NAME<span ui-grid-visible="col.sort.direction" ng-class="{ 'ui-grid-icon-up-dir': col.sort.direction == asc, 'ui-grid-icon-down-dir': col.sort.direction == desc, 'ui-grid-icon-blank': !col.sort.direction }" class="ui-grid-icon-up-dir"> </span>
</div>
<div class="ui-grid-column-menu-button ng-scope" ng-if="grid.options.enableColumnMenus && !col.isRowHeader && col.colDef.enableColumnMenu !== false" ng-click="toggleMenu($event)"><i class="ui-grid-icon-angle-down"> </i></div>
</div>
</div>
.......
我嘗試這樣做: -
jq(".ui-grid-header-cell > .ui-grid-cell-contents").each(function (index, element) {
console.log(element);
});
不給預期的效果。
我想在陣列中的所有頭名。 – Anup 2014-10-31 09:08:00