动态设置连接<a>元素新窗口页面打开
分类:实例代码
本章节分享一段简单的代码实例,它可以动态的设置连接在新窗口中打开页面。
代码实例如下:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.pipipi.net/" /> <title>前端教程网</title> <style type="text/css"> a{ display:block; width:100px; margin:0px auto; } </style> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script type="text/javascript"> $(document).ready(function () { $("a").click(function(){ this.target = "_blank"; }); }) </script> </head> <body> <a href="http://www.pipipi.net">前端教程网</a> </body> </html>
一线大厂高级前端编写,前端初中阶面试题,帮助初学者应聘,需要联系微信:javadudu