|
|
|
@ -1,34 +1,34 @@
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>test_001</title>
|
|
|
|
|
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
<div id = "top01">
|
|
|
|
|
<p id="top02">这是一段文字</p>
|
|
|
|
|
<input type="text" id="in"/>
|
|
|
|
|
<button onclick="getInput()"></button>
|
|
|
|
|
</div>
|
|
|
|
|
</body>
|
|
|
|
|
<script>
|
|
|
|
|
let name;
|
|
|
|
|
function getInput(){
|
|
|
|
|
name = document.getElementById('in').value;
|
|
|
|
|
$.getJSON("js/JSONTEST.json",function(data){
|
|
|
|
|
for(i in data.Title){
|
|
|
|
|
if(data.Title[i].includes(name,0)) name = data.Title[i];
|
|
|
|
|
}
|
|
|
|
|
Title.innerHTML = (name);
|
|
|
|
|
console.log(data);
|
|
|
|
|
});
|
|
|
|
|
console.log(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let Title = document.getElementById('top02');
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<--本文件在edge浏览器下稳定运行,不知道为什么会出现有时候无法正常运行-->
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>test_001</title>
|
|
|
|
|
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
<div id = "top01">
|
|
|
|
|
<p id="top02">这是一段文字</p>
|
|
|
|
|
<input type="text" id="in"/>
|
|
|
|
|
<button onclick="getInput()"></button>
|
|
|
|
|
</div>
|
|
|
|
|
</body>
|
|
|
|
|
<script>
|
|
|
|
|
let name;
|
|
|
|
|
function getInput(){
|
|
|
|
|
name = document.getElementById('in').value;
|
|
|
|
|
$.getJSON("js/JSONTEST.json",function(data){
|
|
|
|
|
for(i in data.Title){
|
|
|
|
|
if(data.Title[i].includes(name,0)) name = data.Title[i];
|
|
|
|
|
}
|
|
|
|
|
Title.innerHTML = (name);
|
|
|
|
|
console.log(data);
|
|
|
|
|
});
|
|
|
|
|
console.log(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let Title = document.getElementById('top02');
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
</html>
|