javascript代码实例教程-(3)选择元素――(4)css选择器(CSS selectors)

发布时间:2019-02-23 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-(3)选择元素――(4)css选择器(CSS selectors)脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。 The jQuery library supports nearly all of the selectors included in CSS sPEcifications 1 through 3, as outlined on the World Wide Web Consortium's sITe: http://www.w3.org/Style/CSS/specs. This support allows developers to enhance their websites without worrying about which browsers (particularly internet Explorer 6) might not understand advanced selectors, as long as the browsers have JavaScript enabled.

jquery支持几乎所有的css1到3的规范,在世界万维网协会网站http://www.w3.org/Style/css/specs有一个概述。这份支持允许开发者扩展他们的网站,而不用担心这是哪一个浏览器(尤其是IE6)或许不懂高级选择器,只要浏览器支持js脚本就行。

PRogressive enhancement

Responsible jQuery developers should always apply the concepts of progressive enhancementand graceful degradationto their code, ensuring that a page will render as accurately, even if not as beautifully, with JavaScript disabled as it does with JavaScript turned on. We will continue to explore these concepts throughout the Book.

渐进增强

有责任感的jquery开发者应该总是应用渐进增强和优雅降级的概念到自己代码中,确保这个网页将会精确的渲染,即使在js被禁用后不是像启用js后的那么漂亮。我们将在整本书中继续探索这个概念。

To begin learning how jQuery works with CSS selectors, we'll use a structure that appears on many websites, often for navigation: the nested, unordered list:

<ul id="selected-plays">

<li>Comedies

<ul>

<li><a href="/asyoulikeit/">As You Like It</a></li>

<li>All's Well That Ends Well</li>

<li>A Midsummer Night's Dream</li>

<li>Twelfth Night</li>

</ul>

</li>

<li>Tragedies

<ul>

<li><a href="hamlet.pDF">HaMLet</a></li>

<li>;macbeth</li>

<li>romeo and Juliet</li>

</ul>

</li>

<li>Histories

<ul>

<li>Henry IV (<a href="mailto:henryiv@king.co.uk&nbsp;

">email</a>)

<ul>

<li>Part I</li>

<li>Part II</li>

</ul>

<li><a href="http://www.shakespeare.co.uk/henryv.htm">

Henry V

</a></li>

<li>Richard II</li>

</ul>

</li>

</ul>

为了开始学习jquery如何使用css选择器工作,我们将使用在很多网站上出现的结构,通常是导航,一个嵌套的无序的列表:(代码如上)

Notice that the First <ul>has an ID of selected-plays, but none of the <li>tags have a class associated with them. Without any styles applied, the list looks similar to the following screenshot:

(3)选择元素――(4)css选择器(CSS selectors)

注意到第一个ul标签有一个selected-play ID,但是任何一个li标签上都没有类。在没有任何样式的情况下,这个列表看起来就像下面的截图一样。

这个嵌套的列表现实的好像我问期望他是一系列元素垂直排列,然后根据级别缩进。

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-(3)选择元素――(4)css选择器(CSS selectors)全部内容,希望文章能够帮你解决javascript代码实例教程-(3)选择元素――(4)css选择器(CSS selectors)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。