JQuery event binding on () and pop-up window implementation code, jquery pop-up window
There are usually pop-up windows on the page. Some pop-up windows are dynamically generated, and some are hidden at the bottom of the page. For dynamically generated pop-up windows, if you want to listen to the pop-up events, you can use jQuery's event binding on () method.
The pop-up window is dynamically generated by js. It is displayed by clicking a link. After clicking the "use now" link in the pop-up window, the effect is to close the pop-up window and jump to the anchor.
The a label is:
Copy codeThe Code is as follows:
<A style = "display:" title = "use" target = "_ blank" gid = "167" href = "http://act.vip. ***. com/vip/2016/51 dps/# gamelist "class =" co_vip tdu "> use now </a>
We want to listen to the click event in the pop-up window, but the pop-up window itself is dynamically generated, so we need to listen to the body and bind it through the on () event. When this pop-up window is dynamically generated, you can listen to the click method:
Function jump_to_anchor () {$ ("body "). on ("click", "span [name = 'msgbox _ info'] ,. act-pop-table a ", function (e) {link = $ (this ). attr ('href '); if (link = 'HTTP: // act. vip. ***. com/vip/2016/51 dps/# gamelist ') {e. preventDefault (); msgExit (); window. location. href = link ;}});}
In fact, two events bound to the tag are bound here. When the link is a url, the default behavior is blocked, and the pop-up window closing method is called to jump to the link, that is, the anchor.