Try this (updated)
function sortInput(el, type, action, val) {
/* `el` : all `input` elements, or, `el#id`, `el.class`, `el[attr]` as `jquery` `object` */
var inputs = $(el);
/* `type` of `$(el)`, i.e.g., `text`, `submit`, `hidden`, etc. */
var type = (type || undefined);
/* if no `newVal` prodided, return `$(this).val() as `default` */
var val = val || $(this).val();
/* `action` to call for `$(el)`, `hide` calls jsquery `.hide()`, `val` calls jquery `.val()` with provided `val` parameter */
$.fn.actions = (action === "hide"
? function() {return this.hide()}
: (action === "val" ? function() {return this.val(val)} : null)
);
/* jquery `.filter()` `$(el)`'s by provided `type` */
return $(inputs).filter(function() {
/* `return` `$(el)`, `filter()`'ed by `type`, call `$.fn.actions()` provided with `action` parameter */
return $(this).attr("type") === type}).actions()
};
/* call `sortInput()`, `.filter()` `type` `submit`, call jquery `.hide()` */
sortInput("input", "submit", "hide");
/* call `sortInput()`, `.filter()` `type` `text`, call jquery `.val()`, with `val` ("newVal") provided parameter */
sortInput("input", "text", "val", "newVal");
Try this (untested)
$(".type").on("change", "input", function (e) {
console.log(e.target); return sortInput("input", "submit", "hide");
});
Hope this helps