-1

jQueryではなくJavaScriptでマウスクリック後にマウスオーバーイベントを呼び出す必要がありますが、主なことは、同じ関数イベントをクリックした後にのみ関数が同じであり、新しいイベントがマウスオーバーであるということですそれは可能ですか?

<a href="javascript:void(0);" id="digit" 
   onClick="javascript:return swapClass(val,val2);" 
   class="GetDivCount" onMouseOver="javascript:return swapClass(val,val2);"> 

わかりましたので、ここで最初にクリックイベントで swapClass() を呼び出す必要があり、クリックイベントの後に同じ関数が onmouseover イベントを呼び出しますが、関数はパラメーター化されていることを覚えておいてください

4

2 に答える 2

-1

jQuery を使用する場合と使用しない場合の 2 つの解決策を次に示します。

それなし:

var control = "";
var first  = document.getElementById("first");
var second = document.getElementById("second");

first.onclick = function(){
    control = true;
    alert("clicked | doSomething Here");
}
second.onmouseover = function(){
        if(control==true){
        alert("mouseovered after click | doSomething Here");
        //if you want again click and after mouseover evenet
        //you have to put here
        //control=""; 
    }
}

と:

$("#first").on("click",function(){
    control = true;
    alert("cilcked | doSomething Here");
});

$("#second").on("mouseover",function(){
    if(control==true){
        alert("mouseovered | doSomething Here");
        //if you want again click and after mouseover evenet
        //you have to put here
        //control="";
    }
});
于 2013-04-08T11:17:29.353 に答える