Is it possible to pass parameters in a jQuery function so that I can use it multiple times with multiple elements? I need to leave it with indeterminate elements and pass them as parameters by determining them when calling the function, just as it is done in the traditional way.
Example: I have the function with determined elements:
$('button').click(function() {
$el = $(this).closest('[id]').attr('id');
$('#s').html($el);
});
I need it more or less like this, with undetermined elements:
function teste($x){
$el = $(this).closest('[id]').attr('id');
$('#s').html($el);
}
then call it by passing the parameter:
<button onclick="teste('meuID');">Pronto</button>
Does anyone have any idea how to perform this feat?