zoukankan      html  css  js  c++  java
  • (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 
    ">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:


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

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

  • 相关阅读:
    c# 改变FileUpload 上传文件大小
    使用ActiveX读取客户端mac地址
    javascript小技巧
    【2012百度之星/资格赛】H:用户请求中的品牌 [后缀数组]
    POJ1012 约瑟夫环问题[双向循环链表+打表技巧]
    北大ACM题分类
    ACM大量习题题库
    POJ1423 计算出n的阶乘的位数大数问题[Stirling公式]
    ACM训练计划(下)
    POJ2080 角度问题[cmath函数]
  • 原文地址:https://www.cnblogs.com/riskyer/p/3324953.html
Copyright © 2011-2022 走看看