JQuery has several colon selectors like
: prev ,: next ,: last
My question is:
prev()
next()
last()
Any basic examples would be really great.
jQuery :prev :next, , . :last, :first, Sizzle, jQuery. , CSS, , , JavaScript.
:prev
:next
:last
:first
:last .last() , , ( , :last :last-child ):
.last()
:last-child
$('.a > .b:last > .c')
, :
$('.a').children('.b').last().children('.c');
, " ", , (, "" ).
.
$('#next').click(function () { if (!$('*').is(':animated')) { if ($('div.display:visible').is(':nth-child(3)')) { $('div.display:visible').fadeOut(); $('div.display:first').fadeIn(function () { $(this).children().fadeIn(); }); } else { $('div.display:visible').fadeOut().next().fadeIn(function () { $(this).children().fadeIn(); }); } } }); $('#prev').click(function () { if (!$('*').is(':animated')) { if ($('div.display:visible').is(':nth-child(1)')) { $('div.display:visible').fadeOut(); $('div.display:last').fadeIn(function () { $(this).children().fadeIn(); }); } else { $('div.display:visible').fadeOut().prev().fadeIn(function () { $(this).children().fadeIn(); }); } } });
eg.
$(".mylist").each(function(){ $(this).css("color","red"); $(this).next().show(); })
The colon is a filter, similar to getting the selected option from the drop-down list that I would use $("select option:selected"), or to get a test box for the radio, I would use$("input[type=radio]:checked");
$("select option:selected")
$("input[type=radio]:checked");
No: prev and: the following filters, but you can find the full list of filters here http://api.jquery.com/category/selectors/