0

我在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;
}
4

1 回答 1

0

您的链接声明中有错字:

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

应该:

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

您不能在另一个""中使用""对。您需要使用'""'或"''"。我很惊讶你的链接完全有效。在此处查看有关 onclick 事件的简单提示。

于 2012-04-07T16:37:59.010 回答