Technical/etc

[Javascript] Keyup call function & pass parameters

sga8 2021. 11. 18. 14:40
728x90
반응형
// JQuery keyup function Implementation
$(document).ready(function(){
    $("#sampleID_One").keyup({param1: "BABO", param2: "TEST"}, otherFunction); // pass param
    $("#sampleID_Two").keyup(otherFunction); // just call function
}));

// other function implementation
function otherFunction(e){
	let sampleID = e.target.id;
	let targetValue = e.target.value;
	let param1 = e.data ? e.data.param1 : "";
    let param2 = e.data ? e.data.param2 : "";

    testFunction(sampleID, targetValue, param1, param2);
}
728x90
반응형