Передача переменной !
Здравствуйте !
Неполучается передать i функции screen_win ! function init() { for (var i = 1; i < 5; i++) { document.getElementById("but_"+i).onmouseover = function(){ screen_win(i)}; document.getElementById("but_"+i).onmouseout = function () { off()}; } } function screen_win(but) { alert (but); //Здесь выводит пять при наведении на любую из кнопок ! if (but== 1) { document.getElementById('screen_win').style.left = "3px" document.getElementById('screen_img').src = "1.jpeg"; } else if (but == 2) { document.getElementById('screen_win').style.left = "68px" document.getElementById('screen_img').src = "2.jpeg"; } else if (but == 3) { document.getElementById('screen_win').style.left = "150px" document.getElementById('screen_img').src = "1.jpeg"; } else if (but == 4) { document.getElementById('screen_win').style.left = "220px" document.getElementById('screen_img').src = "2.jpeg"; } } |
|
Спасибо !
|
Часовой пояс GMT +3, время: 11:39. |