I'm using Jquery mobile framework. I have 2 html files which has two buttons each. The clicking on one button will navigate to other html file. Javascript loaded in each html file will handle a click event in the HTML files. Problem here is , .JS loaded from second html file which is navigated from first html file could not be called. It shows error.

> 
> Error: p.attr("href") is undefined  
> 
>  Source File: file:///Users/Aspire/Development/JQuery%20Mobile/sample/jquery.mobile-1.0a2.min.js  
> 
>  Line: 96
> 
> 
> 

What's going wrong? 

Edited: test.html

html-tags. Under Headertag

```
    <link rel="stylesheet" href="jquery.mobile-1.0a2.min.css" />
    <script src="jquery-1.4.4.min.js"></script>
    <script src="jquery.mobile-1.0a2.min.js"></script> 
       <script type="text/javascript">   
        $(function(){
            $('#test').click(function(){
                alert('This is a general button!');
            });
        });
       </script>
  <Bodytag>
    <div data-role="content">
    <div data-role="page">
        <a id="test" data-role="button" data-inline="true" data-theme="b">Click here</a>
        <a href="~Development/JQuery Mobile/sample/test2.html" data-role="button" data-inline="true" >Navigate to two</a>
    </div>
    </div>
</Bodytag>

```

In the second html. test2.html

html-tags. Under Headertag

```
    <link rel="stylesheet" href="jquery.mobile-1.0a2.min.css" />
    <script src="jquery-1.4.4.min.js"></script>
    <script src="jquery.mobile-1.0a2.min.js"></script> 
       <script type="text/javascript">
        $(function(){
            $('#test2').click(function(){
                alert('This is a general button!');
            });
        });
       </script>
  <Bodytag>
    <div data-role="content">
    <div data-role="page">
        <a id="test2" data-role="button" data-inline="true" data-theme="b">Click here</a>
        <a href="~Development/JQuery Mobile/sample/test.html" data-role="button" data-inline="true" >Navigate to two</a>
    </div>
    </div>
</Bodytag>

```

It works fine when test2.html is opened separately in browser. Even after returning to test.html, it gives same error. Javascript is not called. i.e. only one time, Javascript works fine when .html is launched for first time. After navigation to other page, Javascript is not called.