I'm working on a website that uses a textbox and does something with what the user submits.
On my index page where I use no PHP (all HTML), Javascript tabs that I would like to use work perfectly fine. However, after the user types something in and submits, the next loaded page has PHP. The PHP page calls a function to print the HTML, but even if this page is the exact same as the previous index page, the tabs don't work at all.
...
<article id="navtabs" class="grid col-full">
    <h2>Tabs</h2>
    <div class="">
        <ul class="tabs clearfix">
            <li><a href="#tab1">First</a></li>
            <li><a href="#tab2">Second</a></li>
            <li><a href="#tab3">Third</a></li>
        </ul>
        <div class="tab_container">
            <article id="tab1" class="tab_content">
                <p>Lorem ipsum dolor sit amet</p>
            </article>
            <article id="tab2" class="tab_content">
                <h6>Heading</h6>
                <p>Lorem ipsum dolor sit amet</p>
            </article>
            <article id="tab3" class="tab_content">
                <h6>Heading</h6>
                <p>Lorem ipsum dolor sit amet</p>
            </article>
         </div>
      </div>
</article>
...
The Javascript code in my scripts.js file looks like this:
$(document).ready(function() {
...
//TABS
var tabContents = $(".tab_content").hide(), 
    tabs = $("ul.tabs li");
tabs.first().addClass("active").show();
tabContents.first().show();
tabs.click(function() {
    var $this = $(this), 
        activeTab = $this.find('a').attr('href');
    if(!$this.hasClass('active')){
        $this.addClass('active').siblings().removeClass('active');
        tabContents.hide().filter(activeTab).fadeIn();
    }
    return false;
}); 
...
});
Any ideas why this would work when using HTML only but not when put inside a PHP function?
Edit for clarification: In the version that works it's simply plain HTML. In the version that doesn't I'm doing an echo of the HTML. This is the version that fails.
 
     
    