JSFiddle - React, Tailwind, and code Playground

by Dineshkani

HTML

<div id="firstdiv" value="sample">
    <div id="secondiv">
        Hello world
    </div>
</div>

JavaScript

//jquery

alert($("#firstdiv").attr('id')); //Gets the attribute id of the given element

//Javascript 

alert(document.getElementById("firstdiv").getAttribute("id")); //Gets the attribute of the given element.