Finding Immediately Adjacent Siblings

Written by jdsharp on 14.07.2008 | Code-bits, jQuery 101

Greetings! Here’s a quick tip for advanced filtering of adjacent sibling nodes.
Given the following HTML:
<ul>
<li>Item 1</li>
<li class=”hello”>Item 2</li>
<li class=”hello” id=”three”>Item 3</li>
<li class=”hello”>Item 4</li>
<li>Item 5</li>
<li class=”hello”>Item 6</li>
</ul>
If you needed to select the immediate siblings of #three that matched the class .hello (so the resulting element set would be Item 2, Item 3, Item 4) there […]

Set Focus to the Next Input Field with jQuery

Written by jdsharp on 27.05.2008 | Code-bits, JavaScript, Plugin-Extension

Setting focus to input fields is easy enough with JavaScript: document.getElementById(’theInputField’).focus(); but sometimes you need a more generic solution as what happens when the next input field changes ID?
I was recently faced with the problem of setting focus to the next input field. The challenge was that I didn’t know what that field was. So […]

jQuery as an Associative Array - Dynamically calling jQuery functions

Written by jdsharp on 15.05.2008 | Code-bits, jQuery 101, jQuery Core

So how many times have you done the following:

var elm = $(’.selector’);
if ( elm.hasClass(’selectedElement’) ) {
elm.removeClass(’abc’);
} else {
elm.addClass(’abc’);
}

One alternative to the above example is to use jQuery’s toggleClass() method, but toggleClass does exactly that, toggles the class without a way for us to know the current state.
So now to the point of this post, accessing […]

jQuery 1.2.3 Released (Quietly!)

Written by jdsharp on 07.02.2008 | jQuery Blogs & Sites, jQuery Core

I saw on this as part of the jQuery UI post on Ajaxian today, jQuery 1.2.3 was quietly released last night.
jQuery UI Google Groups Post
Here you go:
http://code.jquery.com/jquery-1.2.3.js
http://code.jquery.com/jquery-1.2.3.min.js
http://code.jquery.com/jquery-1.2.3.pack.js