I’m making a simple input slider in pure javascript (no jQuery). It works perfectly except for one little flaw: I need to call it in the html as
<div id="test0" data-options="A;B;C;D;E" class="myslider"></div>
instead of the more natural
<input type="hidden" class="myslider" data-options="A;B;C;D;E" id="test0">
The reason for that is that I depend on document.getElementById(name).innerHTML=... to add the necessary markup to it. So my question is: what can we do to replace, append, modify, replace… html text around an <input>? The innerHTML seems not to work, and I fail to find an alternative.
Create
<div>, insert<div>, changeinput‘sid?Now you can change
sliderto your heart’s content. I’d recommend checking out the DOM API instead of throwing HTML into things, though. HTML is messy.