wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes testing jQuery selectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "testing jQuery selectors" Watch "testing jQuery selectors" New topic
Author

testing jQuery selectors

J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1040
    
  13

This is probably one of those things that everyone except me already knows about, but I'm sharing it anyway because it's worth a bookmark.

I was struggling with a jQuery selector and went looking for a testing framework when I found this page. I'm not usually very impressed with the stuff from w3schools, but this is very handy.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1752
    
    2
Why bother shuttling your HTML out to some external page?

For most of my purposes I just open the JavaScript console in the browser and do something like $('p').length; or $('p').css('border', 'solid 2px red'); Or depending on which browser you're using just $('p') will give you a handle on the set of elements, which you can then drill down through.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

I also set one of these up for the chapter 2 example code of jQuery in Action (2nd ed) at http://www.bibeault.org/jqia2/chapter2/lab.selectors.html

But I also agree with Mike: sometimes it's easier just to do it locally on your own HTML using the JavaScript console. If this is not something you are familiar with, you should not write another single line of JavaScript until you learn to use it. It's the #1 best tool you need.

P.S. I avoid w3schools just on principle.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: testing jQuery selectors