Crop ảnh với plugin: Jcrop

E-mail Print PDF

Demo: http://deepliquid.com/projects/Jcrop/demos.php

Download: http://deepliquid.com/content/Jcrop_Download.html

Rất hữu ích nếu bạn muốn cho người dùng xử lý, cắt ảnh để làm avatar đúng ko?

Last Updated ( Wednesday, 23 September 2009 13:54 )
 

Kiểm tra form trước khi submit với plugin: Validation

E-mail Print PDF

Demo: http://jquery.bassistance.de/validate/demo/

hoặc: http://docs.jquery.com/Plugins/Validation

Download: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Giả sử có 1 form như sau:

  1. <form class="cmxform" id="commentForm" method="get" action="">
  2.  <fieldset>
  3.    <legend>A simple comment form with submit validation and default messages</legend>
  4.    <p>
  5.      <label for="cname">Name</label>
  6.      <em>*</em><input id="cname" name="name" size="25" class="required" minlength="2" />
  7.    </p>
  8.    <p>
  9.      <label for="cemail">E-Mail</label>
  10.      <em>*</em><input id="cemail" name="email" size="25"  class="required email" />
  11.    </p>
  12.    <p>
  13.      <label for="curl">URL</label>
  14.      <em>  </em><input id="curl" name="url" size="25"  class="url" value="" />
  15.    </p>
  16.    <p>
  17.      <label for="ccomment">Your comment</label>
  18.      <em>*</em><textarea id="ccomment" name="comment" cols="22"  class="required"></textarea>
  19.    </p>
  20.    <p>
  21.      <input class="submit" type="submit" value="Submit"/>
  22.    </p>
  23.  </fieldset>
  24.  </form>
 
 

Để kiểm tra form cách đơn giản nhất là:

  1.   <script>
  2.   $(document).ready(function(){
  3.     $("#commentForm").validate();
  4.   });
  5.   </script>
 

Read more...
 

Truy cập thuộc tính của một phần tử - attr()

E-mail Print PDF

Phương thức attr() dùng để truy cập thuộc tính của một phần tử, chính xác là phần tử đầu tiên mà ta dùng hàm $() để chọn.

Ví dụ: 

Có 1 input text:

  1. <input type="text" name="textfield" id="textfield" value="Dau Huy" />
 

Để lấy giá trị của nó thì đơn giản như sau:

  1. $(":submit").click(function(){
  2.                     var t = $("#textfield").attr("value");
  3.                     $("#test").text(t);
  4.                     return false;
  5.                 });
 
 

Code đầy đủ:

Last Updated ( Tuesday, 22 September 2009 13:22 ) Read more...
 

Ajax trong jQuery với phương thức get()

E-mail Print PDF

(PHP Code Vn Group) - Demo:

http://anhxtanh3087.comoj.com/jQuery-Ajax/get.htm

  • jQuery.get( url, [data], [callback], [type] )
Các tham số urldata giống phương thức load.
callback: là hàm được gọi khi dữ liệu được tải về thành công (khác phương thức load nhé,ở phương thức load hàm sẽ luôn được gọi khi mà request kết thúc không kể là thành công hay thất bại) !
  1. function (data, textStatus) {
  2.   // data could be xmlDoc, jsonObj, html, text, etc...
  3.   this; // the options for this ajax request
  4. }
 
 
type: kiểu của dữ liệu được trả về cho hàm callback: "xml", "html", "script", "json", "jsonp", hoặc "text".

Phương thức jQuery.get( url, [data], [callback], [type] ) có tác dụng tải 1 trang bằng Ajax với phương thức GET.

Last Updated ( Wednesday, 22 April 2009 17:33 ) Read more...
 

Ajax trong jQuery với phương thức load()

E-mail Print PDF

(PHP Code Vn Group) - Demo:

http://anhxtanh3087.comoj.com/jQuery-Ajax/load.htm

  • load( url, [data], [callback] ) 
url: URL của file chứa dữ liệu cần tải về.
data: cặp key/value (dữ liệu, thường là từ form) ta muốn gửi lên server.
callback: hàm sẽ được thực thi khi mà ajax request hoàn thành (không nhất thiết là thành công)
  1. function (responseText, textStatus, XMLHttpRequest) {
  2.   this; // dom element
  3. }
 
 

Phương thức load( url, [data], [callback] ) có tác dụng tải dữ liệu từ 1 file (qua ajax) và gắn dữ liệu đó vào các phần tử DOM được chọn.

Last Updated ( Wednesday, 22 April 2009 16:44 ) Read more...
 
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  3 
  •  4 
  •  5 
  •  6 
  •  7 
  •  Next 
  •  End 
  • »
Page 1 of 7

Đề cử phpLemon

POLLS

Bạn thích sử dụng JavaScript Framework nào nhất?
 

Alexa Rank


Who's Online

We have 1 guest online