久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      jquery可以獲取鏈接的內(nèi)容嗎

      可以獲取。獲取鏈接內(nèi)容的兩種方法:1、使用jquery text()獲取鏈接文本內(nèi)容,語法“$("a").text()”;2、使用jquery attr()獲取鏈接url內(nèi)容,即href屬性的值即可,語法“$("a").attr("href")”。

      jquery可以獲取鏈接的內(nèi)容嗎

      前端(vue)入門到精通課程:進入學習

      本教程操作環(huán)境:windows7系統(tǒng)、jquery3.6.1版本、Dell G3電腦。

      jquery可以獲取鏈接的內(nèi)容。

      在網(wǎng)頁中,使用標簽 <a>來設置超文本鏈接。

      <a href="url">鏈接文本</a>

      因此鏈接內(nèi)容可分為兩情況:

      • 鏈接文本內(nèi)容

      • 鏈接url內(nèi)容

      針對不同情況,jquery有不同的獲取方法。

      1、使用jquery text()獲取鏈接文本內(nèi)容

      text() 方法可返回被選元素的文本內(nèi)容,會返回所有匹配元素的組合的文本內(nèi)容(會刪除 HTML 標記)。

      $("a").text();

      示例:

      <!DOCTYPE html> <html> 	<head> 		<meta charset="UTF-8"> 		<script src="js/jquery-3.6.0.min.js"></script> 		<script> 			$(document).ready(function() { 				$("button").click(function() { 					var con=$("a").text(); 					console.log(con); 				}); 			}); 		</script> 	</head> 	<body> 		<a href="https://www.php.cn/">超鏈接文本</a><br><br> 		<button>獲取鏈接文本內(nèi)容</button> 	</body> </html>

      jquery可以獲取鏈接的內(nèi)容嗎

      2、使用jquery attr()獲取鏈接url內(nèi)容

      鏈接url內(nèi)容就是href屬性的值;而attr() 可返回被選元素的屬性值。

      $(selector).attr(attribute)
      • attribute :規(guī)定要獲取其值的屬性。

      只需要使用attr() 可返回a元素的href屬性的值即可。

      <!DOCTYPE html> <html> 	<head> 		<meta charset="UTF-8"> 		<script src="js/jquery-3.6.0.min.js"></script> 		<script> 			$(document).ready(function() { 				$("button").click(function() { 					var con=$("a").attr("href"); 					console.log(con); 				}); 			}); 		</script> 	</head> 	<body> 		<a href="https://www.php.cn/">超鏈接文本</a><br><br> 		<button>鏈接url內(nèi)容</button> 	</body> </html>

      jquery可以獲取鏈接的內(nèi)容嗎

      【推薦學習:jQuery視頻教程、web前端視頻】

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號