MVC 응용 프로그램에서 양식이 있고 2 개의 비동기식 AJAX 호출을 만듭니다. 1은 새 페이지의 데이터를 가져오고 다른 하나는 검색 결과를 표시합니다. 이 호출 이전에 폼의 초기로드가 정상입니다. 나는 행 바를 색칠하고 싶다.JQuery - 변경 이벤트를 연결할 수 없습니다.
$("#tblePagedList").on("change", styleRows);
function styleRows() {
$("#tblePagedList tr:even").addClass("row1");
$("#tblePagedList tr:odd").addClass("row2");
}
그러나 새 페이지로 이동하거나 검색을 수행하면 이러한 스타일이 적용되지 않습니다. 변경 시도를 시도하는 시도가 실패합니다.
$("#tblePagedList").on("change", styleRows);
또는
즉$("#tblePagedList").change(styleRows);
내 표는 아래와 같다;
<table id="tblePagedList">
<thead>
<tr>
<th>
Company
</th>
<th>
Address
</th>
<th style="width:100px;">
Telephone
</th>
<th style="width:100px;">
Contact
</th>
<th style="width:100px;">
Trade
</th>
<th></th>
</tr>
</thead>
<tbody id="tblePagedListBody"></tbody>
@foreach (var item in Model) {
<tr>
<td>
@item.Company
</td>
<td>
@item.AddressLine
</td>
<td>
@item.Telephone
</td>
<td>
@item.Contact
</td>
<td>
@item.TradeName
</td>
<td>
@Html.ActionLink("Details", "DetailsSubcontractor", new { id = item.CompanyId })
</td>
</tr>
}
을 왜 순수 CSS? '#tblePagedList tr : n 번째 자식 (짝수) {/ * 스타일 정의 * /}'http://caniuse.com/#feat=css-sel3 –
CSS 솔루션이 작동합니다. 고맙습니다! – arame3333