Chris Hardcastle

Techical developer for websites in London

Jquery input selectors

I have a had file on my desktop for months now called “must-learn.txt” I thought I would share it. Every now and then I need to select form elements. I find the follwing very useful, but can never remember the conventions off the top of my head.

For documentation, please see the Jquery documentation. Using the firebug console, you can test the following javascript commands on any of your own forms.


// find a div with an id of "edit-taxonomy"
$("div[id=edit-taxonomy]").each(function(i,item){
console.log("Found");
})
// find a textarea with that has edit anywhere in the id
$("textarea[id*='edit']").each(function(i,item){
console.log("Found");
})
// find an input that has an id that starts with title
console.log($("input[id^='title']").length);

Leave a Reply


My Twitter updates

  • hardcastle There's new examples I've not seen already on the #raphaeljs framework website. Pretty cool!
  • hardcastle Wow, couch.io just got a new design and content! #couchdb
  • hardcastle @mark_xDDD it feels very stable. Installation was perfect. It's only good if it fits your needs!
  • hardcastle @mark_xDDD I'm installing kubuntu 10.04 tonight!

youTube videos

Luke gives a half smile

Luke gives a half smile

This video was uploaded from an Android phone.

Duration: 00:23

Views: 85


Lukes first rattle holding experience

Lukes first rattle holding experience

This video was uploaded from an Android phone.

Duration: 00:44

Views: 26