开发者

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

开发者 https://www.devze.com 2023-03-08 16:02 出处:网络
I\'m using the Hoverintent JQu开发者_JAVA技巧ery plugin to make a DIV expand. Now I want it to work \"on click\" rather than \"on hover\"
  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

精彩评论

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

关注公众号