The page will often have a window, and some of the window is dynamically generated, and some of the window is hidden at the bottom of the page, for dynamically generated window, if you want to listen to the events of the window, you can use jquery event binding on () method implementation.
As shown in the picture, the window is JS dynamic generation, by clicking on a link popup, pop-up window in the "immediately to use" link clicked, the effect is to close the window, and jump to the anchor point.
This a label is:
Xhtml
<a style= "Display:" title= "immediately to use" target= "_blank" gid= "167" href= "/51dps/#gamelist" class= "Co_vip" TDU "> immediately to use </a>
We want to monitor the click event in the window, but the window itself is dynamically generated, so we have to listen to the body, through on () event binding, when dynamically generated this window, you can monitor the click Method:
function Jump_to_anchor () {
$ ("Body"). On ("click", "Span[name= ' Msgbox_info '] a,. act-pop-table a", function (e) {
link = $ (this). attr (' href ');
if (link = = '/51dps/#gamelist ') {
E.preventdefault ();
Msgexit ();
window.location.href = link;
}
});
}
This is actually a binding of two-a-tag event bindings, both when the link is a URL, blocks the default behavior, and calls the close window method to jump to the link, which is the anchor point.
Example
For example, there are two elements below on the page:
<input type= "button" Name= "addbtn" value= "button Add"/>
<div id= "Test" ></div>
Use the jquery code below to see the difference:
$ (function () {
var a = 1,
$_div = $ (' #test ');
$ (' input[name=addbtn] '). On (' click ', function () {
$_div.append (' <input type= "button" name= "Test ' + A + '" value= "button ' + A + '"/> ');
a++;
});
Even item Click event
$_div.on (' Click ', ' Input[name^=test]:even ', function () {
Alert (' I am a valid on method, can you see me: ' + this.value ');
});
Click events for odd-numbered items are found to be invalid, but live methods are available to support
$ (' input[name^=test]:odd '). On (' click ', function () {
Alert (' I am invalid on method, you cannot see me ');
});
Click events for odd-numbered items are found to be invalid, but live methods are available to support
$ (' input[name^=test]:odd '). Live (' click ', function () {
Alert (' I am the live method, can you see me: ' + this.value ');
});
});
Code is simple, do not put the demo page, if there is nothing to understand, you can leave a message