Я хочу получить количество элементов из тега. Это мой исходный код:Ошибки при запуске Javascript-кода в Tomcat
<table class="tablehienthi" id="table">
<thead class="theadhienthi">
<tr>
<th class="thhienthi">Niên Khóa</th>
<th class="thhienthi">Hệ Đào Tạo</th>
</tr>
</thead>
<tbody class="tbodyhienthi">
<tr class="trhienthi">
<td class="tdhienthi"><a style="text-decoration: none; color: rgb(30, 144, 255);" href="#">Niên Khóa 2010-2015</a></td><td class="tdhienthi">Cư Nhân</td>
</tr>
<tr class="trhienthi">
<td class="tdhienthi"><a style="text-decoration: none; color: rgb(30, 144, 255);" href="#">Niên Khóa 2010-2015</a></td><td class="tdhienthi">Kỹ Sư</td>
</tr>
<tr class="trhienthi">
<td class="tdhienthi"><a style="text-decoration: none; color: rgb(30, 144, 255);" href="#">Niên Khóa 2009-2014</a></td><td class="tdhienthi">Cư Nhân</td>
</tr>
</tbody>
Когда я запускаю код в браузере, если я не запустить его с TOMCAT затем код:
$(".tablehienthi tr").children().length return 8
иначе, если я бегу с котом:
$(".tablehienthi tr").children().length return 0.
Я не понимаю? Я хочу получить $(".tablehienthi tr").children().length
, когда я буду работать с tomcat. Полный мой исходный код:
<body>
<table class="tablehienthi" id="table">
<thead class="theadhienthi">
<tr>
<th class="thhienthi">Niên Khóa</th>
<th class="thhienthi">Hệ Đào Tạo</th>
</tr>
</thead>
<tbody class="tbodyhienthi">
<tr class="trhienthi">
<td class="tdhienthi"><a style="text-decoration: none; color: rgb(30, 144, 255);" href="#">Niên Khóa 2010-2015</a></td><td class="tdhienthi">Cư Nhân</td>
</tr>
<tr class="trhienthi">
<td class="tdhienthi"><a style="text-decoration: none; color: rgb(30, 144, 255);" href="#">Niên Khóa 2010-2015</a></td><td class="tdhienthi">Kỹ Sư</td>
</tr>
<tr class="trhienthi">
<td class="tdhienthi"><a style="text-decoration: none; color: rgb(30, 144, 255);" href="#">Niên Khóa 2009-2014</a></td><td class="tdhienthi">Cư Nhân</td>
</tr>
</tbody>
</table>
<script src="js/jquery-1.9.1.js"></script>
<script langauage="javascript">
$('document').ready(function(){
var temp= $(".tablehienthi th").children().length;
alert(temp);
});
</script>
</body>
Что? Как вы ожидаете запустить операцию JQuery DOM в Tomcat? Как минимум, нам нужно гораздо больше кода и контекста. – chrylis
@chrylis помогите мне! –
Вы хотите подсчитать строки или данные таблицы? –