toggle() คือ คำสั่งของ jQuery ในหมวดของ Effects มีไว้สำหรับการแสดง และการซ้อน Elements
โดย toggle() จะรวมคำสั่ง show() และ hide() ตรงที่ คำสั่ง toggle() จะรวมคำสั่งทั้ง 2 เข้าไว้ด้วยกัน
แทรก
โค้ด: เลือกทั้งหมด
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
โค้ด: เลือกทั้งหมด
<script>
$( "#showr" ).click(function() {
$( ".show_calen12" ).toggle('slow');
var text = $(this).text();
if(text== 'Show'){
$(this).text('hide');
} else {
$(this).text('Show');
}
});
</script>