JQuery hoverintent: convert "on hover" to "on click"
- 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"
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);
精彩评论