On Feb 4, 2007, at 8:47 PM, Ⓙⓐⓚⓔ wrote:
the great thing about dt and dd, is that they come in pairs!
Well, not always. There can be multiple <dd> elements for each <dt>.
If you run into a situation in which you need to select possibly more
than one <dd> until the next <dt>, you can use John Resig's nextUntil
() plugin:
$.fn.nextUntil = function(expr) {
var match = [];
// We need to figure out which elements to push onto the array
this.each(function(){
// Traverse through the sibling nodes
for( var i = this.nextSibling; i; i = i.nextSibling ) {
// Make sure that we're only dealing with elements
if ( i.nodeType != 1 ) continue;
// If we find a match then we need to stop
if ( jQuery.filter( expr, [i] ).r.length ) break;
// Otherwise, add it on to the stack
match.push( i );
}
});
return this.pushStack( match, arguments );
};
Cheers,
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
$("dt").click( function() {
$(this).next('dd').slideToggle();
});
aught to do it...
On 2/4/07, Alexandre Plennevaux <[EMAIL PROTECTED]> wrote:
hello,
say i have a definition list:
<dt>title </dt>
<dd> this content blabla</dd>
<dt>another title </dt>
<dd> another content blabla</dd>
i would like to have an event triggered on each dt that modifies its
following dd, and only that one.
i tried a few , but cannot get it to work correctly; it's either
all of them
or an erratic move. the closest i got is:
jQuery(function($)
{
$("dt").click( function() {
$("~ dd",this).slideToggle();
});
});
can you tip me in the right direction?
Thanks
alex
--
Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.441 / Base de données virus: 268.17.24/668 - Date:
4/02/2007
1:30
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
--
Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/