jquery mobile - 导航栏在点击时不会改变颜色

时间:2011-08-12 03:10:24

标签: jquery-mobile navbar

这个小的jquery移动示例工作正常,但因为重复导航栏,需要两次单击才能更改颜色。我可以通过.click事件解决这个问题,或者重新调整导航栏的位置。

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Page Title</title>   
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>

    <script>
    $('#page1').live('pagecreate', function ()              
        {  
                var section1 = "<p>some code for page 1...</p>";                
                myClone1 = $(section1);                                 
                myClone1.appendTo("#placeholder1").trigger('create');
        });             

    $('#page2').live('pagecreate', function ()              
        {  
                var section2 = "<p>some code for page 2...</p>";
                myClone2 = $(section2);                 
                myClone2.appendTo("#placeholder2").trigger('create');

        });         
        </script>

</head> 
<body> 
    <div data-role="page" id="page1">       
            <div data-role="content">
                    <div data-role="navbar">
                    <ul><li><a data-icon="home" data-transition="none" id="page1" href="#page1">page1</a></li>
                        <li><a data-icon="grid" data-transition="none"  id="page2" href="#page2">page2</a></li>             
                    </ul>
                    </div>
                <div id="placeholder1">Page 1</div>
            </div>      
    </div>

    <div data-role="page" id="page2">       
            <div data-role="content">
                    <div data-role="navbar">
                    <ul><li><a data-icon="home" data-transition="none" id="page1" href="#page1">page1</a></li>
                    <li><a data-icon="grid" data-transition="none"  id="page2" href="#page2">page2</a></li>                                 
                    </ul>
                    </div>
                <div id="placeholder2">Page 2</div>
            </div>
        </div>      
    </div>


</body>
</html>

0 个答案:

没有答案