jQuery Selector fundametals

jQuery Selector :-  jQuery selector work as a CSS selector . CSS selector is used to add style to the HTML Page while jQuery selector is used to add behaviors to the HTML Page. 

Selecting Elements by JavaScript

Selecting Elements by jQuery

document.getElementsByTagName(“p”)[0].innerHTML = “Change the page.”;$(“p”).html(“Change the page.”);
for (i = 0; i <= 4; i++){document.getElementsByTagName(“p”)[i].innerHTML=”Change the page”;

}

$(“p”).html(“Change the page.”);

What is “$” sign means in jQuery?

“$” is not other than “jQuery”. It is symbolic notation of “jQuery” word. 

CSS Selector

jQuery Selector

h1 {text-align: left ;} – Selection by Element.$(“h1”).append () – Selection by Element.
.my_class{position: absolute;} – By Class$(“.my_class”).append() – By Class
#my_id {color: #3300FF;} – By ID$(“#my_id”).append() – By ID

 Example:-

  1. $(“div”).remove () – This will give all the div on the page.
  2. $(“#Id_name”) .remove () – This will give the DOM element having id mentioned.
  3. $(“.class_name”) .remove () – This will give the entire DOM element using class mentioned.
  4. $(“div.class_name”) .remove () – This will give all the div using this class on the page.
  5. $(“div div img”) .remove () – This will select the images under div which is in another div.

 Special Selector

$(this) .remove () – It will select the current element “Current Element”. It’s meaning change throughout the code.

Dwarika Dhish Mishra

My name is Dwarika Dhish Mishra, its just my name and I am trying to bring the worth of my name in to actions and wants to be the solution not the problem. I believe in spreading knowledge and happiness. More over I am fun loving person and like travelling a lot. By nature I am a tester and a solution maker. I believe in the tag line of http://ted.org “Idea worth spreading” . For the same, I have created this blog to bring more and more learning to tester fraternity through day to day learning in professional and personal life. All contents are the part of my learning and so are available for all..So please spread the contents as much as you can at your end so that it could reach to every needful people in testing fraternity. I am pretty happy that more and more people are showing interest to become the part your Abode QA blog and I think this is good sign for us all because more and more content would be before you to read and to cherish. You may write or call me at my Email id: dwarika1987@gmail.com Cell: 9999978609

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.