我有一個表格jQuery的ONCLICK錯誤的複選框
<form name="registration_form" action="<?php echo base_url();?>user/register" method="post" onsubmit="return verify()">
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td class="login_user_td">Click If Want To Edit :</td>
<td><input type="checkbox" name="edit" id="edit" onclick="enable_edit()"/>
</td>
</tr>
<tr>
<td class="login_user_td"> First Name :</td>
<td><input type="text" name="f_name" readonly="true" id="f_name" value="<?php echo $my_info[0]['first_name'];?>">
</td>
</tr>
<tr>
<td colspan="2" align="center" class="login_user_button"><input type="image" style="display: none;"src="<?php echo base_url();?>assets/front_assets/image/edit.gif" /></td>
</tr>
</table>
</form>
現在的複選框編輯有它調用函數onclick事件
enable_edit()
{
if($('#edit').prop("checked", true))
{
alert('true');
}
else
alert('false');
}
的問題是,每當我cleckimg上的複選框,其始終顯示真實。
假設如果我第一次點擊,屬性被檢查,然後它會提醒真實,
下一次當我再次點擊時,這次檢查shud得到檢查,並因此警覺虛警。
,但每次它提醒真實。而且該複選框心不是越來越選中...
請幫我在這母校
您使用的是*二傳手*道具'形式()'在你的榜樣。你的意思是if($(「#edit」)。prop(「checked」))'而不是? –