jquery chaining function issue
<p>i wrote this function to toggle a class name, of next div using jquery chaining function, but it doen't work...</p>

<pre><code>  $('a.back-btn,a.front-btn').click(function(e){
        e.preventDefault();
        $(this).toggleClass('back-btn front-btn').end()
        .next().find('.models').toggleClass('rotated');
})
</code></pre>

<p>in case if i write separate line, then it works fine :</p>

<pre><code>$('a.back-btn,a.front-btn').click(function(e){
            e.preventDefault();
            $(this).toggleClass('back-btn front-btn');
            $(this).next('.models').toggleClass('rotated'); // separate line
        })
</code></pre>

<p>what is the issue with my chaining function, how it need to end a process in case if i use the chaining. i used end(), is it wrong? any best clarification to use end()?</p>

<p>thanks in advance</p>
