使用双击的 Onclick 函数

Onclick functions working with doubleclick?

本文关键字:Onclick 函数 双击      更新时间:2023-09-26

我用JavaScript编写了一段代码onclick提供事件,但不是单击执行,而是双击才能执行:

<­a href="javascript:void(0)" onclick="chatWith("arun")>Arun<­/a>
function chatWith(chatuser) {
createChatBox(chatuser);
$("#chatbox_"+chatuser+" .chatboxtextarea").focus();
}
function createChatBox(chatboxtitle,minimizeChatBox) {
if ($("#chatbox_"+chatboxtitle).length > 0) {
    if ($("#chatbox_"+chatboxtitle).css('display') == 'none') {
        $("#chatbox_"+chatboxtitle).css('display','block');
        restructureChatBoxes();
    }
    $("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus();
    return;
}

链接声明中有拼写错误:

<­a href="javascript:void(0)" onclick="chatWith("arun")>Arun<­/a>

应该是:

<a href="javascript:void(0)" onclick="chatWith('arun')">Arun</a>

不能在另一个 "" 中使用 " 对。您需要使用"或""。我很惊讶你的链接根本有效。查看此处以获取onclick事件的简单小提琴。