Jan
8
2010
8
2010
jQuery Snippets ตอนที่ 1
มาดูวิธีการใช้งาน jQuery กันแบบย่อๆกันบ้างนะครับเปลี่ยนบรรยากาศกันหน่อย ผมว่ามีประโยชน์มากๆเลยครับ เพราะจะได้เรียนรู้วิธีการเขียน jQuery หรือการเรียกใช้ Function บาง Function ที่เราไม่เคยใช้ หรือเอาไว้ศึกษาวิธีอื่นๆในการเขียนที่ชาวต่างชาตินิยมเขียนกันนะครับ
- วิธีการ Refresh src ของ IMG นะครับ
1 2 | $(imageobj).attr('src', $(imageobj) .attr('src') + '?' + Math.random() ); |
- วิธีการ เช็คว่า Image นั้นโหลดเสร็จแล้ว หรือโหลดไม่ได้
1 2 3 4 5 6 | var imgsrc = 'img/image1.png'; $('<img alt="" />').load(function () { alert('image loaded'); }).error(function () { alert('error loading image'); }).attr('src', imgsrc); |
- วิธีการ ไม่ให้ Click ขวา
1 2 3 4 5 | $(document).ready(function(){ $(document).bind("contextmenu",function(e){ return false; }); }); |
- วิธีสั่ง Run Function 5 ครั้งทุกๆ 20 วินาที
1 2 3 4 5 6 7 | var count = 0; function myFunction() { count++; if(count > 5) clearInterval(timeout); //do something } var timeout = setInterval(myFunction, 20000); |
- วิธีเช็คว่า Element ที่เราต้องการตรวจสอบนั้นว่ามีอยู่หรือไม่
1 2 3 | if ($("#elementid").length) { //it does! } |
ที่มา : http://www.tympanus.net
Related Posts
Tags
.data
access iframe
advance
Ajax
attr
bind
browser
canvas
Core
debugs
Deferred
deferred.then
Deferred Object
delegate
DOM
Effect
event
Events
filters
google
HTML
html5
iframe
Image
jquery
jquery.data
jQuery 1.4
jquery 1.5
jQuery 1.6
jQuery 1.7
jquery mobile
jquery plugin
jquery ui
json
live
Plugin
plugins
selector
Selectors
show()
UI
undelegate
validate
welcome
what's jquery
Facebook Development
Google+ Page
Categories
- HTML5 & CSS3 (8)
- jQuery 1.4 (9)
- jQuery 1.5 (6)
- .data (1)
- jQuery 1.6 (3)
- .data (1)
- jQuery 1.7 (4)
- Events (1)
- jQuery Mobile (3)
- jQuery UI (3)
- Mobile (1)
- News (8)
- Others (28)
- Plugin (15)
- The basics of jQuery (9)
- Tips (13)
- คู่มือการใช้งาน jQuery ฉบับ ภาษา ไทย (30)
- Ajax (4)
- Attributes (1)
- Core (1)
- Deferred (3)
- Effects (7)
- Events (3)
- Manipulation (2)
- Selectors (5)
- Traversing (2)
- Utilities (2)

An article by







