Such a requirement, if implemented with the live () method, is simple and easy to understand.
$ (' Nav li, #sb-nav Li, #help li '). Live (' click ', function () {//code ...});
After the 1.7 version of jquery, we recommend that you replace the previous bind, live, and delegate methods with the on method.
The above sentence, if used on, how to write it.
actually see live source code to know that live is actually entrusted doucment for event delegation.
According to this idea, you can bind the on method to the document.
$ (document). On (' Click ', ' #header. Fixed-feedback-bn, #sb-sec. Feedback-bn ', function () {//code ...});
In another case, the on () method binds multiple events and can be written like this:
$ ("Table.planning_grid"). On ({mouseenter:function () {//Handle MouseEnter ...}, Mouseleave:function () {//Handle mouse Leave.}, Click:function () {//Handle click ...}}, "TD");
Finally, multiple selectors are bound with the On () method, and multiple events can be written like this:
$ (document). On ({mouseenter:function () {//Handle MouseEnter ...}, Mouseleave:function () {//Handle MouseLeave ...}, c Lick:function () {//Handle click ...}}, ' #header. Fixed-feedback-bn, #sb-sec. feedback-bn ');
Reprint Please specify: Green Bean Front»jquery event on () method binds multiple selectors, multiple events