Original question based on completely wrong logic :O
$(function() {
var x=0,y=1;
$("#div_id").find("input:text").each(function (i, input) {
$(this).val(""+(i % 2 == 0)?x++:y++);
});
});
If I remove the “”+ from the value, I get this wrong result

instead of what I want, which is this:

Same if I use prop:
$(this).prop("value",""+(i % 2 == 0)?x++:y++);
Same if I prefix the ++
What am I overlooking? Is this an obvious thing?
UPDATE: I completely missed the boat here.
Here is the code I meant to write and it works without the “”
$(function() {
var x=0,y=1;
var inputs = $("#div_id").find("input:text");
var y = Math.ceil(inputs.size()/2);
inputs.each(function (i, input) {
$(this).prop("value",(i % 2 == 0)?++x:++y);
});
});
is interpreted as (see precedence rules)
and
("" + (i % 2 == 0))is always truthy, because both"true"and"false"are non-empty strings. So in your example, you’re usingx++all the time, ignoring they++branch.