Home Ask Login Register

Developers Planet

Your answer is one click away!

Nits February 2016

While resize browser window counter variable value should be incremented by 1 value

I am facing a problem whenever I resize the browser window by (CTRL+SHFT+M) or change the orientation of window. counter_ variable value increament by 4 or 7 instead of 1.


<div id="my_element">
    <span id="text">0</span> window resize.


$(function () {
    var counter_ = 0;
    $(window).on('resize', function () {

Output Should be:

0 window resize.

1 window resize.

2 window resize.




jcubic February 2016


$('#my_element').append('<span class="text">' + (counter_++) + '</span> window resize.');

As in this FIDDLE

Post Status

Asked in February 2016
Viewed 2,706 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life