Posted By

javifr on 10/29/10


Tagged

jquery custom


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Defining your own methods


 / Published in: JavaScript
 

  1. //The name will be alertVal
  2. jQuery.fn.alertVal = function() {
  3. var element = $(this[0]); //That's our element
  4. if (element.val())
  5. alert(element.val()); //That's our element's value
  6. };
  7.  
  8. //This is the way we can use it
  9. $("selector").alertVal();
  10.  

Report this snippet  

You need to login to post a comment.