Original address: 59536781
2. function
(1) Original wording
/* Right-click for tab bindings */
$ (". Tabs Li"). Live (' ContextMenu ', function (e) {
/* Select the current Trigger Event tab */
var subtitle = $ (this). text ();
$ (' #mainTab '). Tabs (' select ', subtitle);
Show shortcut menu
$ (' #tab_menu '). Menu (' show ', {
Left:e.pagex,
Top:e.pagey
});
return false;
});
(2) The wording after adjustment
/* Right-click for tab bindings */
$ (". Tabs"). On ("ContextMenu", "Li", function (e) {
/* Select the current Trigger Event tab */
var subtitle = $ (this). text ();
$ (' #mainTab '). Tabs (' select ', subtitle);
Show shortcut menu
$ (' #tab_menu '). Menu (' show ', {
Left:e.pagex,
Top:e.pagey
});
return false;
});
2. Description
The Live () method in jquery has been deprecated in version jquery1.9 and above, and throws an error if used TypeError: $(...).live is not a function
.
Workaround:
Previous usage:
. Live (events, function)
New method:
. On (EventType, selector, function)
If selector is not required, it can pass NULL
Example 1:
Before:
$ (' #mainmenu a '). Live (' click ', function)
After:
$ (' #mainmenu '). On (' Click ', ' a ', function)
Example 2:
Before:
$ ('. MyButton '). Live (' click ', function)
After (the node closest to MyButton should be used):
$ (' #parentElement '). On (' click ', '. MyButton ', function)
If you do not know the nearest node, you can use the following method:
$ (' body '). On (' click ', '. MyButton ', function)
jquery Live () uses an error, TypeError: $ (...). Live is not a function