(function ( $ ) { $.fn.mutarSelect = function( options ){ // This is the easiest way to have default options. var settings = $.extend({ valueselector:"Agregar nuevo", }, options ); var selector = this; selector.append(""); $(".mutarselect-add").click(function( event ){ event.preventDefault(); //alert($(this).parent(".mutarselect").attr("id")); var father = $(this).parent(selector).attr("id"); //var positionReal = $(this).parent(".mutarselect").offset(); // $("#" + father + " .mutarselect-rm" ).remove(); $(this).parent(".mutarselect").hide(); $("").insertAfter( $($(this).parent(".mutarselect")) ); }); $("form").on("keypress", ".mutarselect-input",function( event ){ if ( event.keyCode == '13' ){ event.preventDefault(); $(this).prev(".mutarselect").prepend(""); $(this).prev(".mutarselect").show(); $(this).remove(); } }); //return this; }; }( jQuery ));