jQuery :target
如果文件的URI包含一個格式化的識別符號,或hash,那麼此選擇器將匹配ID和識別符號相匹配的元素。
選擇jQuery1.9版本新增。
語法結構:
[JavaScript] 純文字檢視 複製程式碼jQuery( ":target" )
程式碼例項:
[HTML] 純文字檢視 複製程式碼執行程式碼<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> a{ width:60px; height:20px; background:#F90; font-size:12px; text-align:center; line-height:20px; position:fixed; right:0px; top:50px; cursor:pointer; display:block; text-decoration:none; } #ant{ width:100%; height:50px; background:#CCC; margin-top:100px; text-align:center; line-height:50px; } </style> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("a").click(function () { $("div:target").css("color", "blue") }) }) </script> </head> <body style="height:1000px;"> <a href="#ant">點選定位</a> <div id="ant">螞蟻部落</div> </body> </html>
上面的程式碼是一個錨點定位,點選連結,那麼就會匹配id屬性值為"ant"的div元素。
特別說明:本案例需要在本機測試,螞蟻部落編輯器點選按鈕會跳轉到首頁。
相關文章
- jQuery event.targetjQuery
- memory_max_target,memory_target,pga_aggregate_target,sga_target
- memory_target、sga_target、pga_target的設定
- Openfiler配置ISCSI Target及FC Target
- “rman target /” 和 “rman nocatalog target /” 區別
- 關於memory_max_target,memory_target,sga_max_size,sga_target
- 【例項】之memory_target、sga_target,pga_aggregate_target關係
- CSS E:targetCSS
- currentTarget VS target
- "rman target /” 和"rman nocatalog target /”區別實踐
- 11g的MEMORY_TARGET和MEMORY_MAX_TARGET
- iOS 配置多targetiOS
- JavaScript event.targetJavaScript
- Centos 7 Iscsi targetCentOS
- Error in invoking targetError
- firewalld: zone的target
- new.target 屬性
- currentTarget與target區別
- iptables:No chain/target/match by the nameAI
- MEMORY_TARGET not supported on this system
- As 除錯 no target device found除錯dev
- iOS Swift 工程使用 TargetiOSSwift
- Target node/queue unavailableAI
- SGA_TARGET Advice
- rman target / debug trace
- FAST_START_MTTR_TARGETAST
- rman: can't open target
- Granules of pga_aggregate_target 494 cannot be more than memory_target (497)
- ORA-00837: Specified value of MEMORY_TARGET greater than MEMORY_MAX_TARGET
- 多Target、元件化實踐元件化
- v$sga_target_advice
- Iscsi Target config lv
- 使用 target="_blank"的時機
- v$pga_target_advice
- sga_target大小調整
- 理解FAST_START_MTTR_TARGETAST
- 測試memory_max_target
- The SGA_TARGET Initialization Parameter (74)