1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| <html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<title>Test</title>
<script language="javascript" type="text/javascript">
function toggleDivs(element, direction) {
otherDiv = null;
if (direction == "next") {
otherDiv = $(element).next("div");
} else {
otherDiv = $(element).prev("div");
}
$(element).toggle();
$(otherDiv).toggle();
}
function updateValue(element, value)
{
prevDiv = $(element).parent("div");
$(prevDiv).prev("div").html(value);
toggleDivs(prevDiv, "prev");
}
</script>
</head>
<body>
<!-- DEBUT SNIPPET -->
<div id="div1" style="margin:20px;border:1px solid #555;cursor:pointer;display:block;" onclick="toggleDivs(this, 'next')" >
Cliquez pour choisir une valeur
</div>
<div id="div2" style="margin:20px;border:1px solid #CCC;display:none;">
<a href="#" onclick="updateValue(this, 'Radio 1')">Radio 1</a>
<a href="#" onclick="updateValue(this, 'Radio 2')">Radio 2</a>
<a href="#" onclick="updateValue(this, 'Radio 3')">Radio 3</a>
<a href="#" onclick="updateValue(this, 'Radio 4')">Radio 4</a>
</div>
<!-- FIN SNIPPET -->
<!-- DEBUT SNIPPET -->
<div id="div1" style="margin:20px;border:1px solid #555;cursor:pointer;display:block;" onclick="toggleDivs(this, 'next')" >
Cliquez pour choisir une valeur
</div>
<div id="div2" style="margin:20px;border:1px solid #CCC;display:none;">
<a href="#" onclick="updateValue(this, 'Radio 1')">Radio 1</a>
<a href="#" onclick="updateValue(this, 'Radio 2')">Radio 2</a>
<a href="#" onclick="updateValue(this, 'Radio 3')">Radio 3</a>
<a href="#" onclick="updateValue(this, 'Radio 4')">Radio 4</a>
</div>
<!-- FIN SNIPPET -->
<!-- DEBUT SNIPPET -->
<div id="div1" style="margin:20px;border:1px solid #555;cursor:pointer;display:block;" onclick="toggleDivs(this, 'next')" >
Cliquez pour choisir une valeur
</div>
<div id="div2" style="margin:20px;border:1px solid #CCC;display:none;">
<a href="#" onclick="updateValue(this, 'Radio 1')">Radio 1</a>
<a href="#" onclick="updateValue(this, 'Radio 2')">Radio 2</a>
<a href="#" onclick="updateValue(this, 'Radio 3')">Radio 3</a>
<a href="#" onclick="updateValue(this, 'Radio 4')">Radio 4</a>
</div>
<!-- FIN SNIPPET -->
</body>
</html> |
Partager