Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Web Technology by (20.3k points)

The logic in the change() event handler is not being run when the value is set by val(), but it does run when a user selects a value with their mouse. Why is this?

<select id="single">

    <option>Single</option>

    <option>Single2</option>

</select>

<script>

    $(function() {

        $(":input#single").change(function() {

           /* Logic here does not execute when val() is used */

        });

    });

    $("#single").val("Single2");

</script>

1 Answer

0 votes
by (40.7k points)

You just have to use a textarea to get multiline handling like this:

<textarea name="Text1" cols="40" rows="5"></textarea>

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...