Last active
December 19, 2015 17:29
-
-
Save atrandafir/5991483 to your computer and use it in GitHub Desktop.
Blur a readonly text field because by default jQuery.blur() does not do it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.readOnlyBlur = function() { | |
return this.each(function() { | |
if ($(this).is('input')) { | |
if ($(this).is('[readonly]')) { | |
var readonly_var=$(this).attr("readonly"); | |
$(this).removeAttr("readonly"); | |
$(this).blur(); | |
$(this).attr("readonly",readonly_var); | |
} else { | |
$(this).blur(); | |
} | |
} else { | |
$(this).blur(); | |
} | |
}); | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment