jquery选择body中的title标记时的异常情况


 jQuery的选择器,在选择body中出现的title标记时,会出现和预期不同的效果,测试代码如下所示。

<html>
  <head>
     <script src="jquery-1.2.js"></script>
     <script>
       $(document).ready (
         function () {
           console.info($("title"));
           console.info($("not_title"));
           console.info($("div title"));
           console.info($("div not_title"));
         }
       );
     </script>
  </head>
  <body>
     <title>a single title tag, can be selected.</title>
     <not_title>a single not_title tag, can be selected.</not_title>
     <div>
       <title>a title tag embeded in div tag, can not be selected.</title>
     </div>
     <div>
       <not_title>a not_title tag embeded in div tag, can be selected.</not_title>
     </div>
  </body>
</html>

 

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3