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
});
The not() is an inbuilt function in jQuery which is just opposite to the filter() method. This function will return all the element which is not matched with the selected element with the particular “id” or “class”. Syntax: $(selector).not(A) The selector is the selected element which is not to be selected.
jQuery :not() SelectorThe :not() selector selects all elements except the specified element.
jQuery not() Method: This method returns elements that do not match a defined condition. This method specifies a condition. Elements that do not match the condition are returned, and those that match will be removed. Mostly this method is used to remove one or more than one elements from a group of selected elements.
It is a jQuery Selector used to select every element that is the first child of its parent. Return Value: It selects and returns the first child element of its parent.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With