开发者

JQuery hoverintent: convert "on hover" to "on click"

  1. I'm using the Hoverintent JQu开发者_JAVA技巧ery plugin to make a DIV expand.
  2. Now I want it to work "on click" rather than "on hover"

How do I do this? I know this is simple simple JQuery, but my knowledge is lacking. Any help would be much appreciated. Here is the code:

$(document).ready(function(){
    //Expand Div
    $("#expandbutton").click({
        over: ExpandDiv, 
        timeout: 100, 
        out: DoNothing
    });
}); 


function ExpandDiv(){  
    $("#expander").animate({"height":200},400, "easeOutSine");
    $("#expandbutton").css({opacity: 0.0, visibility: "hidden"}).animate({opacity: 0.0});
}


To simply execute that ExpandDiv method on click, you can use jQuery's .click() like this:

$(document).ready(function(){
    //Expand Div
    $("#expandbutton").click(ExpandDiv);
}); 


Call the function directly after passing your parameters to the click()

 $("#expandbutton").click({timeout: 100, out: DoNothing},
              ExpandDiv);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜