How to change text via jQuery?

Posted by Will Merydith on Stack Overflow See other posts from Stack Overflow or by Will Merydith
Published on 2010-12-30T21:48:38Z Indexed on 2010/12/30 21:53 UTC
Read the original article Hit count: 126

Filed under:
|
|
|

I am trying to change the "show more" text depending on the state. This isn't working:

        <div id="description">
        text goes here
            </div>
            <div id="more-less-container">
                <a href="#" id="more-less">expand / collapse</a>
            </div>  
            <script>
            var open = false;
            $('#more-less').click(function() {
                if (open) {
                    $('#description').animate({height:'10em'}); 
                    $('#more-less').innerHTML ='show less';             
                }
                else {
                    $('#description').animate({height:'100%'});
                            $('#more-less').innerHTML ='show more'; 
                }
                open = !open;
            });
            </script>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery