저는 자바 스크립트와 jquery에 대한 새로운 아이디어가 많습니다.이 메뉴에 대해 조금만 노력해 왔지만 마침내 "완료"되었지만 iv 몇 가지 끔찍한 코드가 있고 그것을 더 읽기 쉽고 기능적으로 만들 수있는 코드를 개선 할 수있는 방법을 찾고 있습니다. 팁과 힌트가 도움이 될 것입니다. 생각이 여기에 코드.hide() .show() div 메뉴의 javascript/Jquery 개선
<body>
<div class="content">
<div class="menu" id="menu"></div>
<div class="content" id="sort"></div>
<div class="menu"id="menu1"></div>
<div class="content" id="1sort"></div>
<div class="menu"id="menu2"></div>
<div class="content" id="sort2"></div>
</div>
<script>
var show = true;
var show2 = false;
var show3 = false;
$('#1sort').hide("fast");
$('#sort2').hide("fast");
$("#menu").click(function() {
if (show == true) {
$('#sort').hide("fast");
$('#1sort').show("fast");
show = false;
show2 = true;
} else if (show == false) {
$('#sort').show("fast");
$('#1sort').hide("fast");
$('#sort2').hide("fast");
show = true;
show2 = false;
show3 = false;
}
});
$("#menu1").click(function() {
if (show2 == true) {
$('#1sort').hide("fast");
$('#sort2').show("fast");
show2 = false;
show3 = true;
} else if (show2 == false) {
$('#1sort').show("fast");
$('#sort').hide("fast");
$('#sort2').hide("fast");
show = false;
show2 = true;
show3 = false;
}
});
$("#menu2").click(function() {
if (show3 == false) {
$('#1sort').hide("fast");
$('#sort').hide("fast");
$('#sort2').show("fast");
show = false;
show2 = false;
show3 = true;
}
});
</script>
우리가 작업 할 수있는 작업 [jsfiddle] (http://jsfiddle.net)을 만드는 것이 좋습니다. 지금은 마크 업에 내용이 없으므로이 방식을 구상하기가 어렵습니다. –