JAVASCRIPT UPDATE ATTRIBUTE

john rob

Total Post:108

Points:756
Posted by  john rob
 972  View(s)
Ratings:
Rate this:

<input type="text" name="araButon" onKeyUp="return arama()" class="form-control filter" data-filter="app" id="focusedInput"/>

I want to update 'data-filter' value by javascript

I tried this code :

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: Javascript Update Attribute

    You can use dataset or setAttribute,

    // dataset

    document.getElementById('focusedInput').dataset.filter = "test";

    // setAttribute

    document.getElementById('focusedInput').setAttribute('data-filter', 'test-1');

    <input type="text" name="araButon" onKeyUp="return arama()" class="form-control filter" data-filter="app" id="focusedInput" />

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!