0

I am new on this field. Here is some code.

    window.blockMenuHeaderScroll = false;
    $(window).on('touchstart', function(e) {
    if ($(e.target).closest('.main').length == 1) {
            blockMenuHeaderScroll = true;
    }
    });

This is part of one javascript code in html tag. I don't know what blockMenuHeaderScroll mean and tried to look up it here. https://developer.mozilla.org/en-US/docs/Web/API/Window

But can't find it. Why is that?

And I also don't know what is closest('.main').length mean. Why there is one "." and why ".length"

Weiheng Li
  • 565
  • 8
  • 19
  • 1
    You're not working with just vanilla javascript in that snippet. Try the jQuery docs as well. https://api.jquery.com/closest/ – Cameron Hurd Oct 18 '16 at 01:41
  • And the snake begins to eat it's tail. Looks like this snippet was cribbed from another SO answer somewhere along the way. Hope this can shed more light: http://stackoverflow.com/a/17159809/1779433 – Cameron Hurd Oct 18 '16 at 01:43
  • 1
    `window` is just an object. `window.blockMenuHeaderScroll = false;` sets a new property called `blockMenuHeaderScroll` on it. You can find `closest` in the [jQuery documentation](https://api.jquery.com/closest/) or on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest), the meaning of the dot in [CSS selectors](https://drafts.csswg.org/selectors/#overview) and `.length` is a property on the jQuery object. – Sebastian Simon Oct 18 '16 at 01:44

0 Answers0