.parent {
position: relative;
width: 200px;
height: 300px;
background: #000;
margin: 0 auto;
}
.child {
position: absolute;
top: 50px; left: 50%;
width: 100vw; margin-left: -50vw;
height: 100px;
background: #f00;
} this['foo']() // плохо
this.foo() // хорошо
// в крайнем случае никто не мешает вам сделать так:
var a = this.foo;
a();var $menu = $('.menu'),
$items = $menu.find('li'),
num = $items.length,
current = -1;
$(document).on('keyup', function (e) {
var key = e.which;
switch (key) {
case 38:
current--;
if (current < 0) {
current = num - 1;
}
break;
case 40:
current++;
if (current > num - 1) {
current = 0;
}
break;
};
$items.eq(current).addClass('active').siblings().removeClass('active');
}); var max = 1000;
if (x < 0) {
x = max;
} else if (x > max) {
x = 0;
}