Home > DeveloperSection > Forums > Javascript Update Attribute
john rob

Total Post:108

Points:756
Posted on    June-03-2015 7:11 AM

 HTML JavaScript 
Ratings:


 1 Reply(s)
 562  View(s)
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 :



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    June-03-2015 7:12 AM

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" />


Don't want to miss updates? Please click the below button!

Follow MindStick