for 루프를 사용하여 javacript에 동적으로 10 개의 값을 인쇄해야합니다. 여기서는 레이블을 인쇄합니다.동적으로 JavaScript를 사용하여 레이블에서 선택된 값 가져 오기
지금은 라벨에 특정 텍스트를 클릭하면 그 텍스트 이름을 가진 하나 명의 경고, 어떻게이 작업을 수행하는 데 도움이
중 하나를 표시 할 수 있습니다.
<html>
<head>
<script type = "text/javascript">
var x = "";
function checkCookie(){
var arr = new Array("One","Two","Three");
for(var i=0; i<arr.length; i++) {
x = x + arr[i] + "<br>" + "<br>";
document.getElementById("idval").innerHTML = x;
}
}
function getItem(){
// here i want to display the selected label item
}
</script>
</head>
<body onload = "checkCookie()">
<label id = "idval" onclick = "getItem()"> </label>
</body>
</html>
일부 코드를 보여줍니다. http://whathaveyoutried.com –
혼자 가면 위험 할 수 있습니다. [Fiddle] (http://jsfiddle.net/WLKm8/)을 가지고 계십시오.) – C5H8NNaO4
@Glutamat ThankYou, Working Great – User