-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtextClear.js
More file actions
36 lines (34 loc) · 1.04 KB
/
textClear.js
File metadata and controls
36 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* ===================================================
* textClear.js v0.0.3
* jQuery Plugin to clear input field text on fly - like as provided in Internet Explorer 10
*
*==========================================================================================
* The MIT License (MIT)
*
* Copyright(c)2013 Exex Zian
*
* =========================================================================================
* Requires: textClearStyle.css and jQuery.js
* =========================================================================================
*/
; (function($) {
$.fn.textClear = function() {
$(this).on({
'keypress' : function(e) {
$(this).addClass('crossClear');
},
'focusout' : function() {
$(this).removeClass('crossClear');
},
'click' : function(e) {
if (($(this).hasClass('crossClear'))) {
var mousePosInElement = e.pageX - $(this).position().left;
if (mousePosInElement > $(this).width()) {
$(this).removeClass('crossClear');
$(this).val('');
}
}
}
});
}
})(jQuery);