【发布时间】:2018-10-24 14:05:22
【问题描述】:
在 jquery 的帮助下,我创建了一个脚本,用外部 .txt 文档中的文本替换 html 页面中的文本。但不知何故它不起作用:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
$('select[name="dropdown"]').change(function(){
if ($(this).val() == "2"){
$.ajax({url: "demo_test2.txt", success: function(result){
$("#div2").html(result);
}});
});
</script>
</head>
<body>
<div id="div2"><h2>John</h2></div>
<select name="dropdown">
<option id="button" value="1">English</option>
<option id="button2" value="2">Dutch</option>
</select>
</body>
</html>
【问题讨论】:
标签: jquery ajax function select