在界面中加入了两个按钮,左边的按钮“确定”点击时可以触发onclick事件,右边的按钮“编辑”就不行。
样式如下:
<form #checkcontacts-dialog>
<p class="maskinglayer_p">
<p class="add_contacts_frame">
<p id="check_contacts_head">
<p id="checkcontacts_label"><label>查看联系人</label></p><button id="checkcontacts_close" class="regist_close_orange"></button>
</p>
<p id="check_contacts_footer">
<table>
<tr><td>姓名</td><td><input id="check_contacts_footer_name" type="text" disabled /></td></tr>
<tr><td>手机号码</td><td><input id="check_contacts_footer_phone" type="text" disabled /></td></tr>
<tr><td>固定电话</td><td><input id="check_contacts_footer_officephone" type="text" disabled /></td></tr>
<tr><td>qq号码</td><td><input id="check_contacts_footer_qq" type="text" disabled /></td></tr>
<tr><td>电子邮箱</td><td><input id="check_contacts_footer_email" type="text" disabled /></td></tr>
<tr><td>备注说明</td><td><textarea id="check_beizhushuoming" disabled></textarea></td></tr>
</table>
<button id="check_bt" class="show_add_bt"></button>
<button id="edit_bt" class="edit_bt"></button>
</p>
</p>
</p>
</form>
截图如下所示:
两个按钮的事件如下:(采用tiscript)
$(#check_bt).onClick = function()
{
$(#checkcontacts-dialog).state.collapsed = true;
}
$(#edit_bt).on("click",function(evt)
{
$(#checkcontacts-dialog).state.collapsed = true;
dialog {body:$(form#altercontacts-dialog)};
})
事件是用tiscript写的,语法是正确的。
我在交换两个按钮的ID之后,左边的按钮也可以执行id为edit_bt的事件。
请各位指点迷津。
It’s because in CSS, the height and width of the image button block the scope of the edit button.
$(#check_bt).onClick = function()
{
}
I have never seen this way of writing. It quotes jq and uses the onclick method of js, and your js also reports an error
Try using document for event delegation.
The selector is not quoted?