We would like to know how to toggle html content.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(function(){<!-- ww w . j av a 2s .c o m-->
$('#foo').toggle(function() {
$(this).html('▲ HIDE ▲');
}, function() {
$(this).html('▼ SHOW ▼');
});
});
</script>
</head>
<body>
<div id="foo">▼ SHOW ▼</div>
</body>
</html>
The code above is rendered as follows: