How can I say..
On Click .not.first() div
alert('Yeah you clicked a div which is not the first one!');
My actual code:
this.$('thumbnails').children().click(function() {
$('#video').animate({width: 164, height: 20, top:开发者_开发百科 475, marginLeft: 262},0)
$('.flv').animate({left: 2222, opacity: '0'},0).css('display', 'none')
$('.close').animate({opacity: '0'},0)
clicked = 0
});
There's a :gt()
(greater-than-index) selector or .slice(1)
(@bobince's preference :), your question translated literally would be:
$("div:gt(0)").click(function() {
alert('Yeah you clicked a div which is not the first one!');
});
//or...
$("div").slice(1).click(function() {
alert('Yeah you clicked a div which is not the first one!');
});
For your updated question:
$('thumbnails').children(":gt(0)").click(function() {
$('#video').css({width: 164, height: 20, top: 475, marginLeft: 262});
$('.flv').css({left: 2222, opacity: '0'}).hide();
$('.close').css({opacity: '0'});
clicked = 0;
});
//or...
$('thumbnails').children().slice(1).click(function() {
$('#video').css({width: 164, height: 20, top: 475, marginLeft: 262});
$('.flv').css({left: 2222, opacity: '0'}).hide();
$('.close').css({opacity: '0'});
clicked = 0;
});
Note the use of .css()
, if you want to make instant non-animated style changes, use this istead.
$(div).not(":first").click(function(){
alert("Yeah you clicked a div which is not the first one!);
});
see :first and .not from the jquery docs.
$('thumbnails').children().not(":first").click(function() {
$('#video').animate({width: 164, height: 20, top: 475, marginLeft: 262},0)
$('.flv').animate({left: 2222, opacity: '0'},0).css('display', 'none')
$('.close').animate({opacity: '0'},0)
clicked = 0
});
Would be the answer for the update to your question.
$("#id").not(':first').click(function(){
alert('Not the first');
});
$('div').not(':first').click(function() {
alert('Yeah you clicked a div which is not the first one!');
});
For your updated question:
$('thumbnails').children().not(':first').click(function() {
$('#video').animate({width: 164, height: 20, top: 475, marginLeft: 262},0)
$('.flv').animate({left: 2222, opacity: '0'},0).css('display', 'none')
$('.close').animate({opacity: '0'},0)
clicked = 0
});
精彩评论