我正在使用的.toggle()
功能有问题。我正在使用 PHP 从数据库中获取结果并用信息填充表格。每个表格行中的最后一项是一个链接,单击该链接时应显示另一行,允许管理员编辑该产品的信息。链接的类是.edit_prod
这是我的 jQuery 方法:
$(function() {
$(".edit_prod").click(function() {
$("#mydiv").toggle();
return false;
});
});
有人可以帮我解决可能出现的问题吗?
谢谢!
更新:
这是创建 HTML 的 PHP 代码
$table_format = sprintf("
<tr>
<td>
<img src='%s' id='edit_img_pic' />
</td>
<td>
%s
</td>
<td>
%s
</td>
<td>
<a class='edit_prod' href='#'>Edit</a>
</td>
</tr>
<tr id='mydiv' style='display: none' cellspacing='20px'>
<form action='edit_product.php' method='post'>
<td>
<label for='name'>Product Name</label><br>
<input type='text' name='name' value='%s' /><br><br>
</td>
<td>
<label for='sku'>SKU</label><br>
<input type='text' name='sku' value='%s' /><br><br>
</td>
<td>
<label for='price'>Price</label><br>
$<input type='text' name='price' value='%s' /><br><br>
</td>
<td>
<label for='desc'>Description</label><br>
<textarea cols='40' rows='7' name='desc'></textarea><br><br>
<input type='submit' value='Save' />
</form>
<tr>
", $img, $prod_name, $sku, $prod_name, $sku, $price);
echo $table_format;
更新 2: