Following are the below selectors,filters which are used in common in jquery.
Below selectors are specified with correspoding purposes.
detttach :Temporarily Removes from the DOM.
remove : Removes Peremanently from the DOM.
append: Attach any content.
parent :Travelse to it parent level object.
children :Travelse to its beneath objects
prev : Travelse to the Left side of the elements.
Ex:-
.previous() it moves to the
next : Travelse to the Right side of the elements.
Ex:-
.next() it moves to the
replaceWith :This will replace the content.
$(“.meat”).replaceWith(”
“);
Filter:
1)first
2)last
3)slice:-slice(1,3) This returns the second element.
4)not:- Returns all the Elements which doesnt pocess that quality.
5)eq: Equals.
Ex:-$(“.fish).eq(1);
This returns the first element of fish class.
6)before():
Append a tag before the tag.
$(“.fish”).before(”
“);
This will result putting Handsome before the fish.
7) after()
Append a tag before the tag.
$(“.fish”).after(”
“);
This will result putting Handsome after the fish.
8)not
It will result all the children whose heading are not h4.
Ex:-
$(“.left_col”).children().not(“h4″);
9) Filter()
DOM manipulation You can add to, replace, and remove things from the DOM at will:
detach
remove
replaceWith
before
after
Filters
Filter methods help you narrow down a set of selected elements:
first
equal
last
slice
filter
not
Fade effects
Change the opacity property of CSS
elements: fadeInfadeOut
fadeTo
Slide effects
Change the height property of CSS
elements:
slideUp
slideDownslideToggle
animate
Lets you create custom animations when out-of-theboxjQuery effects aren’t enough.
Animates CSS properties over time. Only works with CSS properties that have numerical settings.
Elements can be moved either absolutely or relatively.
Operator combinations (=, +, -) make relative animation much easier.
–JQueryObject–
planeObject={
engines:”4″,
type:”passenger”,
propellor: “No”};
Now we can acess the elements like planeObject.engines.
var myCountry = {
getCapital : function() {
alert(this.myCapital);
},
myName : ‘USA’,
myCapital : ‘Washington DC’
},
Now we can access the object in this fashion.
myCountry.getCapital()
this will show the alert message.
This is soemthing like Class.methodname();
$.inArray(): For identifying the element in the Array.
Ex:-
var haystack = new Array(‘hay’, ‘mouse’, ‘needle’, ‘pitchfork’)
Synatax:
var index = $.inArray( value, array );
Identfying needle in the haystack.
var needle_index = $.inArray( ‘needle’, haystack );
On from Jquery 1.7.
Ex:-Surfing all the elements under accepmenu whose elements are a
$(‘#accpmenu’).on(‘click’, ‘a’, function () {
//this gets the index by finding the first parent list-item element and getting it’s index compared do its siblings
var selected_index = $(this).parents(‘li’).index();
alert(selected_index);
});
