🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ <title>Document</title> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> </head> <body> <img src="images/movie.webp" alt="" id="img"> <p>评分:<span id="average">8.2</span></p> <form > <input type="text" id="user" name="user"> <input type="button" id="btn" value="搜索"> </form> <script> var user = document.getElementById("user"); var btn = document.getElementById("btn"); var img = document.getElementById("img"); var average = document.getElementById("average"); btn.onclick = function(){ var url ="https://douban.uieee.com/v2/movie/search?q="+user.value+"&count=1"; $.ajax({ url, type:"get", dataType:"jsonp", success:res=>{ /* 渲染数据 */ var averageData = res.subjects[0].rating.average; var imgUrl = res.subjects[0].images.small; img.src=imgUrl; average.innerHTML = averageData; } }) } </script> </body> ~~~