jQuery :first
此選擇器匹配元素集合中的第一個元素。
jQuery1.0版本新增。
語法結構:
[JavaScript] 純文字檢視 複製程式碼jQuery( ":first" )
程式碼例項:
[HTML] 純文字檢視 複製程式碼執行程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#bt").click(function () { $("li:first").css("color", "blue"); }); }); </script> </head> <body> <ul> <li>螞蟻部落一</li> <li>螞蟻部落二</li> <li>螞蟻部落三</li> <li>螞蟻部落四</li> </ul> <input type="button" value="檢視效果" id="bt" /> </body> </html>
將li元素集合中第一個li元素字型顏色設定為藍色。
相關文章
- jQuery first()jQuery
- jQuery :first-of-typejQuery
- jQuery :first-childjQuery
- Head First jQuery讀書筆記jQuery筆記
- OCP(11g)-----> oracle First In First Out (FIFO)/Last In First OutOracleAST
- :first-child與:first-of-type 區別
- Entity Framework Code-First(2):What is Code-First?Framework
- Entity Framework Code-First(4):Simple Code First ExampleFramework
- Entity Framework Code-First(5):Code First ConventionsFramework
- first oracle sqlOracleSQL
- FIRST_ROWS和FIRST_ROWS_n的區別
- FIRST_ROWS和FIRST_ROWS(N)的區別 (zt)
- Annotation for ANDROID ---FirstAndroid
- linux c firstLinux
- raw device, first blockdevBloC
- My First Blog
- My first blog!
- 【EF Core】Code first
- CSS E:first-childCSS
- CSS E:first-of-typeCSS
- CSS E::first-letterCSS
- First Missing Positive【hard】
- ZOJ First Digit(瞎搞)Git
- My first Upgrade projectProject
- Patterns and Frameworks (my first topic)Framework
- First steps with Incus
- css選擇器中:first-child與:first-of-type的區別CSS
- 學習總結(first week)
- EF Core 的 Code First 模式模式
- Head First HTML and CSS (八)HTMLCSS
- Head First Python (一)Python
- ! [rejected] master -> master (fetch first)AST
- Chapter 1 First Sight——35APT
- Chapter 1 First Sight——22APT
- 分析函式——NULLS FIRST/LAST函式NullAST
- Could Cassandra be the first breakout NoSQL databaseSQLDatabase
- Creating your first iOS FrameworkiOSFramework
- Entity Framework Tutorial Basics(11):Code FirstFramework