이 코드는 작동하지 않습니다. 이유가 무엇입니까?자바 스크립트 숨기기 show hide
<script>
function color(color_type){
if (color_type == 'blue'){
document.getElementById('blue').style.display = 'block';
document.getElementById('red').style.display = 'none';
}
else{
document.getElementById('blue').style.display = 'none';
document.getElementById('red').style.display = 'block';
}
}
</script>
<select onchange="color(this.value)">
<option name="choice1" value="red" >red</option>
<option name="choice2" value="blue" >blue</option>
</select>
<div id="red" style="display:none;">
<?
//
echo "<tr>
<td width='100' class='tbl'>Just ask</td>
<td width='80%' class='tbl'><input type='text' name='1' value='$n1' class='textbox' style='width: 250px'></td>
</tr>";
//
?>
</div>
<div id="blue" style="display:none;">
<?
//
echo "<tr>
<td width='100' class='tbl'>Just ask blue</td>
<td width='80%' class='tbl'><input type='text' name='2' value='$n2' class='textbox' style='width: 250px'></td>
</tr>";
//
?>
</div>
Td 테이블은 숨길 때마다이 테이블을 표시합니다. 파란색 또는 빨간색으로 표시하려면 "파란색으로 물어보기"또는 "그냥 묻기"를 선택해야합니다.
P.S 내 나쁜 영어
아래에 표시됩니다 : http://jsfiddle.net/fkling/nTczy/. 'tr' 요소 **는'table' ('thead', tbody','tfoot') 요소의 하위 요소 여야하며'div' 자식이 될 수 없습니다. –
여기에 CSS가 있습니까? –
이 코드가 작동하는지 확인했습니다. 브라우저에서 캐시를 제거하십시오. – Chinmay235