This code works:
$('[id$=lbl]').val() == "0" ? alert('Bla') : null;
but this codes don’t:
$('[id$=lbl]').val() == "0" ? function(){alert('Bla'); return false; } : null;
$('[id$=lbl]').val() == "0" ? alert('Bla');return false; : null;
$('[id$=lbl]').val() == "0" ? return false : null;
i need “alert” after “return false”
How can I do that ?
you have to do like this:
$('[id$=lbl]').val() == "0" ? (function(){alert('Bla'); return false; })() : null;function(){alert('Bla'); return false; }is just declaration of the function. Brackets will execute it: (declaration of function…)()EDIT:
do you mean that you need to do like this?:
function bla(){ return ($('[id$=lbl]').val() == "0" ? (function(){alert('Bla'); return false; })() : (function(){return null;})() ); }explanation:
the function will return whatever ( condition ? val1 : val2 ) expression will return… in this case val1 and val2 are both functions and they are returning some values(val1 -> false; val2 -> null;) and that value is returned by main(bla) function.