Вход

Просмотр полной версии : Помогите зациклить чередование


CTACOH
16.03.2013, 13:25
<SCRIPT LANGUAGE="javascript">
function test() {
alert('11111');
document.getElementById('test').onclick=function () {
alert('22222');
}};
</SCRIPT>

<p><strong id='test' onclick="test();">Click here</strong></p>

azolkin
16.03.2013, 14:28
<p><strong id='test'>Click here</strong></p>
<script>
var counter = 0;
document.getElementById('test').onclick = function () {
if (counter == 0) {
counter = 1;
alert('11111');
}
else {
counter = 0;
alert('22222');
}
}
</script>

рони
20.03.2013, 11:17
:)
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
</head>

<body>
<p><strong id='test'>Click here</strong></p>
<script>
var s = [22222,11111];
document.getElementById('test').onclick = function () {
alert(s.reverse()[0]);
}
</script>
</body>
</html>