I just stumbled upon this FIDDLE online. JS is as follows:
$(function() { $('#add').click(function() { return !$('#select1 option:selected').appendTo('#select2'); }); $('#remove').click(function() { return !$('#select2 option:selected').appendTo('#select1'); }); });
HTML ::
<SELECT id="select1" name="select1" size="3"><OPTION value="1">Test 1</option><OPTION value="2">Test 2</option></select> <SELECT id="select2" name="select2"></select> <br><input type="button" id="add" value="Add >>"><input type="button" id="remove" value="<< Remove">
This is basically a piece of JS replacing the selected values. But I do not understand how to use the operator ! (not an operator).
Now I understand that the operator not inverts the result, but in the code above, what does it really do? I donβt understand what the operator does not in the aforementioned violin, and what effect does this have on the final result? Can someone explain?
source share