Home > Backend Development > PHP Tutorial > How to display the value of the drop-down box in jq

How to display the value of the drop-down box in jq

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-09-06 08:42:54
Original
929 people have browsed it

I want to write something like this
There is a drop-down box. When a value is selected, the currently selected value is displayed in a div. When switching other drop-down options, the value in the div will also change.

This is my code, but it doesn't work. What's wrong?

<code><body>
    <script src="http://keleyi.com/keleyi/pmedia/jquery-1.9.1.min.js"></script>

<select id="s">
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>
    <option value="4">Option 4</option>
</select>
    <script type="text/javascript">
        $('#k').on('change', function()
{
    document.write($("#s").val());
    
});
    </script>
    <div id="k"></div>
</body>value值
我想在div#k中显示当前选中的下拉选项</code>
Copy after login

Excuse me what’s wrong

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template