1 <a id= "Workframe" href= "pages/work.html" target= "Framebox" > Home </a> 2
3 $ ("#workFrame"). Tigger ("click");
The above code, in fact, is quite normal, but how can not trigger the A-tag click event. Baidu for a moment, the solution is as follows
1 <a id= "Workframe" href= "pages/work.html" target= "Framebox" ><span id= "Aspan" > Home </span></a> 23 $ ("#aSpan"). Tigger ("click");
Of course there is a problem here, that is, why the click event triggering a SPAN will trigger the Click event of a tag, which is an event bubbling process
1, the event source triggers the onclick event, and then its parent element also triggers the Click event, after which its grandparent element then triggers the click event until the HTML element (the standard and support events bubble, also supports event capture, event capture is the opposite of event bubbling, from HTML to the event source, Of course, our great ie in principle can not be associated with it, have their own style, only support event bubbling)
2, of course, can also prevent event propagation
• Using the Stoppropagation () method in the
• Set cancelbubble = True under IE;
3, you can also block the default behavior, such as Click <a> Jump ~
• Use the Preventdefault () method in the user's list;
• Set window.event.returnValue = False under IE;
On the specific content of event propagation: former focus on http://www.jb51.net/article/42492.htm
jquery trigger <a> Tag's Click event is invalid