javascript - While resize browser window counter variable value should be incremented by 1 value -
i facing problem whenever resize browser window (ctrl+shft+m) or change orientation of window. counter_
variable value increament 4 or 7 instead of 1.
html:
<div id="my_element"> <span id="text">0</span> window resize. </div>
script:
$(function () { var counter_ = 0; $(window).on('resize', function () { $('#text').text(++counter_); }); });
output should be:
0 window resize.
1 window resize.
2 window resize.
..
..
try:
$('#my_element').append('<span class="text">' + (counter_++) + '</span> window resize.');
as in fiddle
Comments
Post a Comment