本文實例講述了jQuery實現查找鏈接文字替換屬性的方法,分享給大家供大家參考,具體如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery鏈接文字替換屬性</title> <script language="JavaScript" src="jquery-1.7.2.min.js"></script> <script language="JavaScript" type="text/JavaScript"> $(document).ready(function(e) { var aa = $('a font[title$="首頁"]').html(); if(aa=='首頁'){ $('.page').find('a').eq(0).attr("href", "/page/?type=index"); } }); </script> </head> <body> <div class="page"> <a href="#"><font title="首頁">首頁</font></a> <a href="#">上一頁</a> <a href="#">當前頁</a> <a href="#">下一頁</a> <a href="#">尾頁</a> </div> </body> </html>