Posted By

touffies on 11/12/10


Tagged

ie input jquery


Versions (?)

Function Hint


 / Published in: jQuery
 

Fix IE focus, hover and check if there's a default placeholder name

  1. /* ------------------------------------------------------------------
  2.   Hint ------------------------------------------------------------- */
  3. $.fn.hint = function(settings) {
  4.  
  5. // defaults settings
  6. settings = $.extend({
  7. classFocus: "focus",
  8. classOver: "hover",
  9. classLabelError: "error"
  10. }, settings);
  11.  
  12. return this.each( function() {
  13. var elm = $(this);
  14. var title = elm.attr('title');
  15.  
  16. elm // on focus, set value to blank if current value matches title attr
  17. .bind("focus", function(){
  18. if(settings.classLabelError) { elm.removeClass(settings.classLabelError); }
  19. //if(settings.classLabelError && elm.is(".v-mandatory")) { $("label[@for=" + elm.attr("id") + "]").removeClass(settings.classLabelError); }
  20. if (title && elm.val() == title) { elm.val(''); }
  21. elm.addClass(settings.classFocus);
  22. })
  23. .bind("blur", function(){
  24. if (title && elm.val() === '') { elm.val(title); }
  25. elm.removeClass(settings.classFocus);
  26. })
  27. .addHover(settings.classOver)
  28. .blur();// now change all inputs
  29. });
  30. };

Report this snippet  

You need to login to post a comment.