這篇文章主要介紹了jQuery使用attr()方法同時(shí)設(shè)置多個(gè)屬性值的用法,實(shí)例分析了jQuery中attr方法實(shí)現(xiàn)多個(gè)屬性設(shè)置的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了jQuery使用attr()方法同時(shí)設(shè)置多個(gè)屬性值的用法。分享給大家供大家參考。具體如下:
下面這個(gè)演示例子可通過(guò)點(diǎn)擊按鈕實(shí)現(xiàn)修改鏈接與提示的功能。
- <!DOCTYPE html>
- <html>
- <head>
- <script src="js/jquery.min.js">
- </script>
- <script>
- $(document).ready(function(){
- $("button").click(function(){
- $("#w3s").attr({
- "href" : "http://www.survivalescaperooms.com/",
- "title" : "vevb.com"
- });
- });
- });
- </script>
- </head>
- <body>
- <p><a href="http://www.survivalescaperooms.com/" id="w3s">vevb.com</a></p>
- <button>點(diǎn)此改變鏈接與提示</button>
- <p>鼠標(biāo)滑過(guò)鏈接即可看到鏈接與提示信息已被更改.</p>
- </body>
- </html>
希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選