javascript - Why is my text not being added to the textarea after the second change event? -


i trying add text in the <textarea> when on change event occurs.

it works fine in first change event. when delete text inside text area , preform change event not work add text anymore?

i confused on why not working. below snippet of trying accomplish.

$("#test").on("change", function() {      $("#textarea_test").text("hello");    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <select name="test" id="test">    <option value="test1">test 1</option>    <option value="test2">test 2</option>    </select>    <textarea name="textarea_test" id="textarea_test" cols="30" rows="10"></textarea>

.text changes inner content of textarea, used default value. once value changed user, changing default value won't have effect.

use .val change value, other form control element.


Comments