Home >Backend Development >PHP Tutorial >How to display the value of the drop-down box in jq
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>
Excuse me what’s wrong