大佬教程收集整理的这篇文章主要介绍了javascript – 无法使用jQuery选择器在IE8中选择HTML5元素的子项,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是标记:
<section class="pleaseWaitButton"> <p><img src="images/please_wait.png" alt="Please wait" /></p> <p><input type="image" src="images/add_to_cart.png" alt="Add to cart"/></p> </section>
这是在这种情况下唯一可以工作的jQuery选择器
$('.pleaseWaitButton').length // 1
这里的jQuery选择器将无法正常工作!
$('.pleaseWaitButton').find('input').length // 0 $('.pleaseWaitButton input').length // 0 $('.pleaseWaitButton > p > input').length // 0
有任何想法吗?任何人…?
您需要使用shiv的HTML 5元素,以便对其进行风格和正确使用方法/属性,如innerHTML,getElementsByTagName.
这将在IE6-IE8中工作:
<!doctype html> <html> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <section class="pleaseWaitButton"> <p><img src="images/please_wait.png" alt="Please wait" /></p> <p><input type="image" src="images/add_to_cart.png" alt="Add to cart"/></p> </section> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> <script> alert( $('.pleaseWaitButton').find('input').length ) alert( $('.pleaseWaitButton input').length ) alert( $('.pleaseWaitButton > p > input').length ) </script> </html>
以上是大佬教程为你收集整理的javascript – 无法使用jQuery选择器在IE8中选择HTML5元素的子项全部内容,希望文章能够帮你解决javascript – 无法使用jQuery选择器在IE8中选择HTML5元素的子项所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。