I have this bit of javascript:
$('.step_1 li').click(function(event) {
$(this).find('label').hide();
$(this).find('input').focus();
});
$('.step_1 li input')
.focus(function(){
$(this).prev('label').hide();
})
.blur(function(){
if (!$(this).val()){
$(this).prev('label').show();
}
});
I’d like to be able to just say $('.step_1').inputSwap() so I can reuse it.
So what’s the proper wan to create a jQuery function like this? (I’m running jQuery 1.6.2)
this is how you would turn it into a plugin.
EDIT
some optimizations and fixed li