JQuery – Element selector

Element selector: Select all elements based on the given (HTML) tag name

$('element');
Copy the code

(1) The native getElementsByTagName() method; (2) getElementsByTagName();

<script type="text/javascript">
        var divs = document.getElementsByTagName('p');
        for ( var i = 0; i < divs.length; i++) {
            divs[i].style.border = "5px solid blue";
        }
    </script>
Copy the code

(2) JQuery method $(“)

    </script> -->
      <script type="text/javascript">
        $("div").css("border", "5px solid red");
    </script>    
Copy the code

Div elements

P element