I want to make simple Jquery function like this:
function switchButton($param) {
$param.on('change', function() {
var result = $($param +'.switch-field input[name=switch]:checked').val();
alert(result);
});
}
Execute like this:
switchButton(('.switch-field input'));
Please help to format this function correctly. Thank you.
switchButton($('.switch-field input'));missing the$. And then your inner lookup would need to be changed to$param.find('.switch-field input[name=switch]:checked').val()$('input').val(). Just be aware of the differences.