| attr ( name ) | ใช้คืนค่า ค่าข้อมูล ของ attribute ที่กำหนด จาก first element ของ set |
|---|
syntax:attr ( name )
return type:string, undefined
content:ใช้คืนค่า ค่าข้อมูล ของ attribute ที่กำหนด จาก first element ของ set หรือจะคืนค่า undefined ในกรณีที่ set เป็น empty หรือ first element ไม่มี attributen name ตามที่กำหนด ( ใน jQuery สามารถกำหนด attribute ภายใน tag html เป็นอะไรก็ได้ ซึ่ง jQuery สามารถเรียกใช้ได้ด้วย แต่จะไม่ validate html ตามหลักของ w3c )
example:alert ( $("img").attr("custom") );