これが私のPHPコードです。これでは、テーブルを作成し、データベースからデータを取得してデータを入力しています。2行印刷しています。2番目の表の行に「HelloThere」と書きました。.hide()関数を理解しているので、ページ表示では非表示にする必要があると思います。しかし、それはそうではありませんか?
<table>
<thead>
<tr>
<th>All Courses</th>
<th>Center</th>
<th>Batch</th>
<th>Click for Info</th>
</tr>
</thead>
<tbody>
<?php
if($batch_query != null){
$i = 0;
foreach($batch_query->result_array() as $row){
$val = "'".$row['course_id'].",".$row['center_id'].",".$row['batch_id']."'";
echo "<tr>";
echo "<td>".$row['course_name']."</td>";
echo "<td>"."<button id= \"btn_number_$i\" class='btn info toggler' >Info <i class='icon-arrow-down'></i></button>"."</td>";
echo "</tr>";
echo "<tr class='info_row'>Hello There!!</tr>";
$i++;
}
}
コードでは2つの行を作成していますが、最初はjQueryのhideメソッドを使用して2番目の行のdisplayプロパティをnoneに設定します。
同じページのscriptタグの間にあるjQueryコードは次のとおりです。
$(function(){
console.log('Hello World!!');// Just to test whether the code is being reached or not.
$('.info_row').hide();
});
しかし、このhide()関数は機能していないようです。「Hellothere」という文字列全体がページに残ります。
これの理由は何でしょうか?