Jquery Selectors

Jquery selector allows you to select and manipulate HTML elements. It is used to find HTML elements based on their name, id, class, attribute etc. All selector in Jquery starts with dollar sign ($).

Element Selector
Jquery element selector selects elements based on the element name.

Code Structure
$(document).ready(function(){
  $('button').click(function(){
    $('p').hide();
  });
});


ID Selector
Jquery ID selector selects elements based on the ID name.

Code Structure
$(document).ready(function(){
  $('button').click(function(){
    $('#text').hide();
  });
});


Class Selector
Jquery class selector selects elements based on the class name.

Code Structure
$(document).ready(function(){
  $('button').click(function(){
    $('.text').hide();
  });
});

Share this

Related Posts