jQuery: How can I target a specific tag, such as UL?

Tuesday, July 17th, 2012 | Business | No Comments

jQueryjQuery is a flexible javascript framework that lets you do a lot.  One major component of jQuery is the concept of the “selector“.

If you want to apply some jQuery code to an item, you use it’s selector.  For example to turn on a class for all anchor tags (A) you use:

$(“a“).toggleClass(“className”, true);

The “a” in bold is the “selector”.  In this case we told jquery (which is “$”) to select all anchor tags.  We then said, “with what is selected, toggle the className class on”.

› Continue reading

Tags: , , , , , ,

CSS4: First Spec Released – Selectors

Friday, September 30th, 2011 | Business | No Comments

W3C released the first spec of CSS4 yesterday, and it’s focused on selectors.  Selectors Level 4 introduces many new and useful elements.

Some newly introduced selectors are (where E is an element):

  • E:not (s1, s2)
  • E:matches(s1,s2)
  • E[foo=”bar” i]
  • E:local-link
  • E:local-link(0)
  • E:current
  • E:current(s)
  • E:past
  • E:future
  • E:indeterminate
  • E:default
  • E:in-range, E:out-range
  • E:required, E:optional
  • E:read-only
  • E:read-write
  • E:nth-match(n of selector) – stated twice in the spec for some reason
  • E:column(selector)
  • E:nth-column(n)
  • E:nth-last-column(n)
  • E /foo/ F – this sounds interesting, an F element referenced by E’s foo attribute
  • $E > F – this will be important, it selects the “E” part of what used to only select F (you can still use E>F for the F element)

The current / past / future selectors are interesting.  I’m not entirely sure what the indicators will be.  The document is somewhat vague in whether you will define a “time/date” attribute, or if it’s just before / after in the document hierarchy.  It sounds like there will be graceful degradation.

Of course, CSS4 won’t officially see the light of day likely for a few years.  CSS3 isn’t technically finished yet either.

However, given a previous direction of no more “versions” of HTML.  We can safely assume W3C will begin releasing these specs for browsers to incorporate at their earliest convenience.

It is a double edged sword.  If a spec is implemented differently by different browsers, then we fork web developer code in the ambiguities of the early spec.  Will browsers implement the past/current/future on their own?

Tags: , ,

Please share, it makes me happy:

Subscribe to Email Alerts

Follow Me

Follow seangw on twitter



prestashop theme

virtuemart template