The
click function only applies to matching elements currently on the page. Since there is no
blog-tab-active initially included, it never has any event handler attached. Use the
live function or the new
on function to attach handlers to current or future matching elements:
- $(function() { // Shorthand for $(document).ready(function() {
- $('div.blog-tab').live('click', function() {
- $('div.blog-content-area').animate({width: 'toggle'}, 'fast');
- $(this).removeClass().addClass('blog-tab-active');
- });
-
$('div.blog-tab-active').live('click', function() {
- $('div.blog-content-area').animate({width: 'toggle'}, 'fast');
- $(this).removeClass().addClass('blog-tab');
- });
- });