You appear to be a bot. Output may be restricted
Description
Simple jQuery anonymous functionWhen we want to invoke a function when an item is clicked on or hovered over then we need to be able to specify either an anonymous function as the $parms OR choose a jQuery routine that accepts the child selector, method and parameters as parameters This solution implements the simple anonymous function method. Note: This solution is not intended to implement complex chaining nor effects that require multiple anonymous functions. It's effective when you want to toggle/slideToggle the display when the "selector" is hovered over or clicked on <pre> $("button").click( function () { $("p").slideToggle("slow"); } ); </pre>
Usage
bw_jquery_af( $selector, $method, $af_selector, $af_method, $af_parms );
Parameters
- $selector
- ( string ) required – the selector for the hover/click
- $method
- ( string ) required – the method used to trigger the subsequent processing: e.g. "click" or "hover"
- $af_selector
- ( string ) required – the selector for the anonymous function
- $af_selector
- ( string ) required – the method for the anonymous function: e.g. "slideToggle" or "toggle"
- $af_method
- ( mixed ) required –
- $af_parms
- ( mixed ) optional –
Returns
voidSource
File name: oik/includes/bw_jquery.incLines:
function bw_jquery_af( $selector, $method, $af_selector, $af_method, $af_parms=null ) { $parms = "function() { jQuery(\"$af_selector\").$af_method( $af_parms ); }"; bw_jquery( $selector, $method, $parms ); }View on GitHub View on Trac