jquery-動態設定ul li a連結目標

來源:互聯網
上載者:User

標籤:

概述:

  先上我的布局圖:

  ul中的每一個li裡麵包含著一個‘a‘超連結,可以猜想到,我想沒點擊ul->li裡面每個a,連結到不同的頁面,在這裡,我用iframe完成.

html主要代碼為:

 1 <div class="warp"> 2     <div class="title"> 3         <ul id="fengcai_title"> 4             <li><a href="#">教師的風采1</a></li> 5             <li><a href="#">教師的風采2</a></li> 6             <li><a href="#">教師的風采3</a></li> 7         </ul> 8     </div> 9     <div class="content">10         <iframe  scrolling="auto" target="_parent" id="content_frame" src="content/tar.html"> </iframe>11 </div>

 

  然後下載相關的jquery庫,完整的jquery代碼為:

<script type="text/javascript" src="jq/jquery-2.1.0.min.js"></script><script type="text/javascript" src="jq/jquery-2.1.0-vsdoc.js"></script><script type="text/javascript" src="jq/jQuery2.1.js"></script><script type="text/javascript" >    function dd() {                $("#fengcai_title li a").click(function(){            $("#content_frame").attr(‘src‘, ‘content/‘ + this.innerHTML + ".html");        });    }</script>

  其中,分頁檔統一放在‘content‘目錄中,頁面的檔案名稱和 a中的文字相對應.可以在 body的onload事件中調用該dd()函數.

jquery-動態設定ul li a連結目標

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.