Skip to content
Related Articles

Related Articles

jQuery HTML/CSS Methods Complete Reference

Improve Article
Save Article
  • Last Updated : 25 Nov, 2022
Improve Article
Save Article

JQuery provides methods to control the DOM inefficient way.  JQuery provides methods that act as getter, retrieving information from DOM elements like .attr(), .html(), and .val().

All the selectors included in CSS are supported in jQuery. jQuery CSS Methods are used to apply CSS properties on DOM elements.

Syntax:

$(selector).method(attribute.., function..)

Example: Set text syntax

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1>
    <center>
    Geeks <button onclick="function()">Click me
        </button>
    </center>
</h1>
  
    <script src=
</script>
    <script>
        $(document).ready(function() {
            $("button").click(function() {
                $("p").text("Jquery_text_method");
            });
        });
    </script>
  
    <p>GeeksforGeeks</p>
    <p>Jquery</p>
  
</body>
  
</html>


Output:

 

The complete list of jQuery HTML/CSS Methods is given below:

Methods:

jQuery HTML/CSS Methods 

Description

jQuery addClass() Method This is used to add more properties to each selected element.
jQuery after() Method This is used to insert content, specified by the parameter for each selected element in the set of matched elements. 
jQuery append() Method The append() method in jQuery is used to insert some content at the end of the selected elements. 
jQuery appendTo() Method This is used to insert an HTML element at the end of the selected element. 
jQuery attr() Method This is used to set or return the attributes and values of the selected elements. 
jQuery before() Method This is used to add the content before the selected element. 
jQuery clone() Method This is used to make a copy of selected elements including their child nodes, text, and attributes.
jQuery css() This is used to change the style property of the selected element.
jQuery detach() Method It removes the selected elements from the DOM tree including its all text and child nodes
jQuery empty() Method This is used to remove all child nodes and their content for the selected elements.
jQuery hasClass() Method The hasClass() is an inbuilt method in jQuery that check whether the elements with the specified class name exist or not.
jQuery height() and innerHeight() Method This is used to check the height of an element but it will not check the padding, border, and margin of the element. 
jQuery html() Method The html() Method in jQuery is used to set or return the innerHTML content of the selected element. 
jQuery innerWidth() with Example This is used to return the width of the first matched element.
jQuery insertAfter() Method This is used to insert some HTML content after a specified element.
jQuery insertBefore() Method This is used to insert some HTML content before a specified element. 
jQuery offset() Method This is used to set or returns the offset coordinates of the selected element.
jQuery offsetParent() with Example This is used to find the first positioned parent element in the DOM tree.
jQuery outerHeight() Method This is used to find the outer height of the specified element. 
jQuery outerWidth() Method This is used to return the value of outer width of an element which includes border & padding.
jQuery position() Method This is used to find the position of the first matched element relative to its parent element in the DOM tree.
jQuery prepend() Method This is used to insert a specified content at the beginning of the selected element.
jQuery prependTo() Method This is used to insert HTML elements or some content at the beginning of the selected element.
jQuery prop() Method This is used to set or return properties and values for the selected elements.
jQuery remove() This is used to remove all the selected elements including all the text. 
jQuery removeAttr() Method This is used to remove one or more attributes from the selected elements.
jQuery removeClass() Method This is used to remove one or more class names from the selected element.
jQuery removeProp() Method This is used to remove the property set by the prop() method.
jQuery replaceAll() Method This is used to replace selected elements with new HTML elements.
jQuery replaceWith() Method This is used to replace the selected element with the new one.
jQuery scrollLeft() Method This is used to return or set the horizontal position of the scroll bar.
jQuery scrollTop() Method This is used to return the vertical top position of the scrollbar.
jQuery text() Method This is used to set or return the text content of the element.
jQuery toggleClass() Method This is used to toggle or change the class attached to the selected element.
jQuery unwrap() Method This is used to remove the parent element from the selected element.
jQuery val() Method This is used to return or set the value of an attribute for the selected elements. 
jQuery width() This is used to check the width of an element.
jQuery wrap() Method This is used to wrap the specified element around the selected element.
jQuery wrapAll() Method This is used when the specified element will be wrapped against all the selected elements.
jQuery wrapInner() Method This is used to wrap the HTML element around the content of each selected element.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!