XML 파일을 테이블로 구문 분석하고 jquery tablesorter를 사용하려고합니다. 이제는 기존 테이블러가 없기 때문에 오류가 발생했기 때문에 데이터가 테이블에 채워지지만 헤더를 정렬 할 수는 없습니다. 어떤 아이디어? JS 및 HTML에 대한 코드는 아래에 나열되어 있습니다.jQuery Tablesorter가 열을 정렬하지 않음
HTML :
<html>
<head>
<title>Read XML</title>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript" src="custom.js"></script>
</head>
<body>
<table id="table" border="1">
<thead>
<tr>
<th>Item #</th>
<th>Shape</th>
<th>Weight</th>
<th>Color</th>
<th>Clarity</th>
<th>Price($)</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
JS :
$(document).ready(function() {
$("#table").tablesorter();
$.ajax({
type: "GET",
url: "tutorial.xml",
dataType: "xml",
success: parseXml
});
$("#table").trigger("update");
});
function parseXml(xml)
{
$(xml).find("diamond").each(function()
{
$("#table tbody").after("<tr><td>" + $(this).find("id").text() +
"</td><td>" + $(this).find("shape").text() + "</td><td>" + $(this).find("weight").text() +
"</td><td>" + $(this).find("color").text() + "</td><td>" + $(this).find("clarity").text() +
"</td><td>" + $(this).find("price").text() + "</td></tr>");
});
}
두 가지 오타가 코드를 수정 했습니까? – rekire
그들은 tablesorter의 마지막 질문에서 함수가 아닌 문제를 해결했습니다. – Brandon