Task Using Selecting Attribute of DOM

Task Using Selecting Attribute of DOM

In the Below HTML Code task perform the following :
  • First select the button with the id send by using the querySelector() method.
  • Second, set the value of the name attribute to submit using the setAttribute() method. Then get the value of name attribute.
  • Third, Paragraph is align right in the given HTML; remove the align attribute so that paragraph set to left automatically
  • Fourth, Check align attribute exist or not
  • Last, As we know by default link is blue in color and underline, change into red color and remove the underline.


    <button id=”send”>Send</button>

                <p align=”right”> This is align right Paragraph</p>

                <a href=”http://google.com”>Google</a>




        let send = document.querySelector(‘#send’);


        send.setAttribute(‘name’, ‘submit’);



                                let paragraph = document.querySelector(‘p’);





                                let link = document.querySelector(‘a’);

                                link.style.color = ‘red’;

                                link.style.textDecoration = ‘none’;    


Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *