Skip to content

DOM removeAttribute()

As we create HTML elements in JavaScript, we can create and delete their attributes. For this, we use the setAttribute () method to create the attribute, the removeAttribute () method to delete the attribute, the getAttribute () method to find the attribute value, and the hasAttribute () method to check the attribute.


removeAttribute () removes an attribute from the specified item.
An exception does not occur when you try to remove an attribute that is not on the element.



name: Enter the name of the feature you want to remove.

removeAttribute Examples

Example 1

removeAttribute example

    <input class="txt" type="text" value=""/>
    <button onclick="myAttribute();">REMOVE</button>
        function myAttribute() {



Example 2

removeAttribute example

    <div class="box">
        <input class="txt" type="text" value="box list" />
        <span onclick="removeFunction()"><i class="fas fa-times"></i></span>


        function removeFunction() {





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: