[Solved] How to set font size in textbox using Dropdown list javascript [closed]


You can use jQuery To Simple down the code

LAB DEMO

HTML CODE:

<input type="text" value="Sample Text" id="txtBox" name="name">
<br>
<select id="fontSizeDD">
  <option value="12">12</option>
  <option value="14">14</option>
  <option value="16">16</option>
  <option value="18">18</option>
  <option value="20">20</option>
  <option value="22">22</option>
  <option value="24">24</option>
  <option value="26">26</option>
</select>

jQuery CODE :

$(function(){
  $("#fontSizeDD").change(function(){
$("#txtBox").css("font-size",$(this).val() + "px");
})
});

Pure JavaScript Solution

var fontSizeDD = document.getElementById('fontSizeDD');
fontSizeDD.onchange = function () {
    var txtBox = document.getElementById("txtBox")
    txtBox.style.fontSize = this.value +"px";
};

3

solved How to set font size in textbox using Dropdown list javascript [closed]