Toggling button & content with jQuery This hides div.extended then creates a button that toggles its text and div.extended's visibility.

While the below works, I was wondering if there was a more concise way of writing this code.

(function() {

var extended = $('.extended').hide();

$('&lt;button&gt;&lt;/button&gt;', {
    text: 'Read more'
    }).appendTo('.intro')
        .on('click', function(){
            extended.slideToggle();
        }).toggle(
            function(){
                $(this).text('Read Less')
            },
            function(){
                $(this).text('Read More')
            });

})()
$(function () {
    var extended = $('.extended').hide(),
        hidden = true;
    $('&lt;button&gt;&lt;/button&gt;', {
        text: 'Read more'
    }).appendTo('.intro').on('click', function () {
        extended.slideToggle();
        hidden = !hidden;
        $(this).text(hidden ? 'Read More' : 'Read Less');
    });
});


You only need to bind the click event once (toggle is a shortcut for binding to click and attaching two alternating event handlers).