<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<style type="text/css">
*{
margin: 0;
border: 0;
position: relative;
outline: none;
}
#top{
text-align: center;
margin-top: 200px;
border-bottom: 2px solid gainsboro;
}
#top input{
border-bottom: 1px solid slateblue;
margin-bottom: 10px;
width: 300px;
height: 40px;
text-align: center;
font-size: 25px;
color: mediumorchid;
}
#top button{
background-color: darkorchid;
width: 80px;
height: 40px;
color: white;
font-size: 20px;
cursor: pointer;
}
#bottom{
text-align: center;
font-size: 15px;
}
#bottom textarea{
width: 500px;
height: 500px;
font-size: 20px;
font-weight: 600;
line-height: 30px;
outline: none;
}
</style>
<script type="text/javascript">
window.onload = function(){
function getDream(){
var value1 = $('#top input').val();
var url = 'http://api.tianapi.com/txapi/dream/'
$.get(url,{'key':'772a81a51ae5c780251b1f98ea431b84','word':value1},function(re){
var allData = re.newslist;
if(allData != undefined){
for (var x in allData) {
var titleNode = allData[x];
var wordNode = titleNode.title;
if(value1 === wordNode){
var resultNode = titleNode.result;
$('#bottom textarea').text(resultNode)
}else{
for (var i in wordNode) {
var word1 = wordNode[i];
if (value1 == word1){
var resultNode = titleNode.result;
$('#bottom textarea').text(resultNode)
}
}
}
}
}else{
$('#bottom textarea').text('周公能力有限!')
}
})
}
$('button').on('click',getDream)
}
</script>
</head>
<body>
<div id="top">
<input type="text" name="text" id="text" value="" />
<button>查询</button>
</div>
<div id="bottom">
<p id="dream" style=""></p>
<textarea name="" style=""></textarea>
</div>
</body>
</html>
周公解梦-杀人.png
网友评论