HTML
<div> <p>点击下面的按钮,查看本地IP信息</p> <span class="span">点击查看</span> <p class="cip"></p> <p class="cid"></p> <p class="cname"></p> </div>
CSS
html,body{ height: 100%; } body{ margin: 0 } div{ padding-left: 50px; } .span{ padding: 5px 15px; background: #177ad8; color: #fff; font-size: 14px; text-decoration: none; border-radius: 7px; cursor: pointer; }
JavaScript
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> <script> var ipspan =document.querySelector(".span"); ipspan.onclick =function(){ document.querySelector(".cip").innerHTML =returnCitySN[‘cip‘]; document.querySelector(".cid").innerHTML =returnCitySN[‘cid‘]; document.querySelector(".cname").innerHTML =returnCitySN[‘cname‘]; } </script>
这个接口是搜狐的目前是可用的, 就是不知道以后会不会失效
时间: 2024-11-08 15:36:05