data-title属性

  • Post author:
  • Post category:其他







data-title


属性



使用


jquerymobile


的时候有时候我们会在同一个页面中写多个页面,但是在切换的时候,在浏览器显示的


title


总是同一个。我们需要不同的页面显示不同的


title


,这时候我们可以在


data-role


后面添加


data-title


属性


,设置自己需要的


title


内容








1.

<!DOCTYPE html


>


2.



<html>


3.



<head>


4.



<meta



name

=

“viewport”


content

=

“width=device-width, initial-scale=1”



>


5.



<title>


Multi Page Example (2)


</title>


6.



<link



rel

=

“stylesheet”


href

=

“http://code.jquery.com/mobile/latest/jquery.mobile.min.css”



/>


7.



<script



src

=

“http://code.jquery.com/jquery-1.7.1.min.js”



></script>


8.



<script



src

=

“http://code.jquery.com/mobile/latest/jquery.mobile.min.js”



></script>


9.



</head>


10.


11.



<body>


12.

  1. <div data-role=”page” id=”homePage”>




  2. <div





    data-role


    =


    “header”



    >



    Welcome



    </div>







  3. <div





    data-role


    =


    “content”



    >







  4. <p>




  5. Welcome to our first mobile web site. It’s going to be the best site you’ve ever seen.

  6. Once we get some content. And a business plan. But the hard part is done!




  7. </p>







  8. <p>




  9. You can also



    <a





    href


    =


    “#aboutPage”



    >



    learn more



    </a>



    about Megacorp.




  10. </p>







  11. </div>








  12. <div





    data-role


    =


    “footer”



    >







  13. <i>



    Copyright Megacorp © 2012



    </i>







  14. </div>




  15. </div>


  16. <div data-role=”page” id=”aboutPage” data-title=”About Megacorp”>




  17. <div





    data-role


    =


    “header”



    >



    About Megacorp



    </div>







  18. <div





    data-role


    =


    “content”



    >







  19. <p>




  20. This text talks about Megacorp and how interesting it is. Most likely though you want to




  21. <a





    href


    =


    “#homePage”



    >



    return



    </a>



    to the home page.




  22. </p>







  23. </div>







  24. <div





    data-role


    =


    “footer”



    >







  25. <i>



    Copyright Megacorp © 2012



    </i>







  26. </div>






  27. </div>





  28. </body>





  29. </html>





在我们点击


learn more


链接后,跳转了一个页面,同时


title


会改变为


About Megacorp