button跳转

好多人比较熟悉的就是a 链接。如: <a href="xx.html"></a>。这样的确比较方便。就如我来说,
根本就不会直接写 button 然后方法。but 当我换了一份工作之后,被指出button里面套a,
是不专业 的写法。所以此篇文章主要是介绍button如何跳转。

1.使用a标签**
a标签的超链接可以直接嵌套一个button
	<a href="xx.html">
            <button>点击跳转</button>
        </a>
2.使用onclick属性**
           <button onclick="window.location.href='xx.html'">
            点击跳转
           </button>
3. window.open**
	 <button onclick="window.open='xx.html'">
            点击跳转
           </button>
4.js方法**
     	<button onclick="Jump()">
	    按钮
	</button>
        <script>
		    function Jump(){
		        window.location.href='xx.html'
		    }
	</script>
5.jq方法**
	<button id=‘jump’>
	    按钮
	</button>
	<script>
		  $(document).ready(function(){
		  $('jump').click(function(e){
		  window.open('xx.html')
		})
	})
	</script>

        button 跳转有多种方法,正如‘一千个人眼里有一千个哈姆雷特’,不要拘泥于别人的印象中。

猜你喜欢

转载自blog.csdn.net/cscscscs419/article/details/84954036