Home >Web Front-end >Front-end Q&A >How to control a tag jump in jquery
The jquery method to control a tag jump: 1. Create an HTML sample file; 2. Add other sub-tags to the a tag; 3. Trigger the sub-category tag to jump.
The operating environment of this article: windows7 system, jquery3.2.1 version, DELL G3 computer
jquery How to control a tag jump?
Use jquery to trigger a tag jump
Error example
<a href="http://www.baidu.com" target="_blank">baidu</a> // 直接是触发click事件是无法跳转的 $('a#toMain').trigger('click') ;
Correct example
// 如果要用jquery触发进行跳转,那么a标签中【必须要有其它子标签】,然后触发该子类标签才能进行跳转 <a href="http://www.baidu.com" target="_blank"> <p>baidu</p> // 要有子标签 </a> // 这里触发的是a标签中的p标签 $('a#toMain>p').trigger('click') ;
JavaScript encodes the url URL, using encodeURIComponent That’s it
var myUrl = 'http://www.baidu.com'; var myOtherUrl = "http://www.jb51.net/index.html?url="+encodeURIComponent(myUrl);
Recommended learning: "jquery video tutorial"
The above is the detailed content of How to control a tag jump in jquery. For more information, please follow other related articles on the PHP Chinese website!