xmanman

导航

 

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<title>Document</title>
</head>
<body>
<input type="text" id="txt">
<select id="test">
<option value="option-1">option-1</option>
<option value="option-2">option-2</option>
<option value="option-3">option-3</option>
</select>

<script>


$(document).ready(function() {
document.getElementById("txt").value = document.getElementById("test").value;
document.getElementById("test").onchange = function() {
document.getElementById("txt").value = this.value;
}
});
</script>

</body>
</html>

posted on 2019-03-08 23:12  xmanman  阅读(399)  评论(0编辑  收藏  举报