Skip to content

Instantly share code, notes, and snippets.

@alanerzhao
Created July 19, 2013 07:21
Show Gist options
  • Save alanerzhao/6037307 to your computer and use it in GitHub Desktop.
Save alanerzhao/6037307 to your computer and use it in GitHub Desktop.
$(function (){
var tmpl = '<span class="text-close js-text-close" href="#"></span>',
textIpt = $(".text-ipt");
textIpt.each(function () {
var self = $(this);
$(this).after(tmpl);
$(this).next().css("display","none");
self.bind("keyup focus",function (){
if(!self.val() == ""){
$(this).next().show();
} else {
$(this).next().hide();
}
})
$(this).next(".js-text-close").click(function (){
self.val("");
$(this).hide();
})
self.bind("blur",function (){
var self = $(this);
setTimeout(function (){
console.log(1);
self.next().hide();
},100)
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment