jQuery’s toggleClass function

While looking up something else in the jQuery documentation just now I discovered a useful function "toggleClass" to toggle a CSS class on and off.This post doesn’t really offer anything more than what is in the jQuery documentation ( the toggleClass manual page is here) but simply serves to draw your attention to this very useful function.

jQuery: Changing the default text value on focus, and showing plain text in a password field Part 1

Last year I posted a couple of jQuery articles about how to change the default text value on focus and show plain text in a password field and then make it a regular password field on focus, with examples in the pages about how to do it. I did not post a full standalone working example which someone requested a couple of days ago, so follow those posts up here with a full standalone example.

jQuery Form Selectors

There are a number of different <input> types in HTML and jQuery makes it simple to select the different types of input elements, such as all the text fields, all the radio buttons, all the submit buttons and so on. Full information and examples can be found on the selectors page of the jQuery document; this post gives some examples and a summary of the possible selectors.

@ selector is deprected in jQuery, removed in jQuery 1.3

In my how to check and uncheck a checkbox with jQuery and how to get and set form element values with jQuery posts I used @name= selectors for some of the form elements but have since discovered the use of the @ was already deprecated and has been removed in jQuery 1.3.

One of my previous examples looked like this, to work out if a checkbox was checked:

$('input[@name=foo]').is(':checked')
$('input[@name=foo]').attr('checked')

To make the code valid for jQuery 1.3 you need to remove the @ symbols and do this instead:

$('input[name=foo]').is(':checked')
$('input[name=foo]').attr('checked')

The use of these selectors without the @ also works in the jQuery 1.2 branch. I am not sure if it works in older versions.