我要的效果就是点击 IP 后,显示省市地址,现在效果已经实现,但是不知道为什么,需要点击两次连接后才可以显示出返回的结果.小白一枚,谁能帮忙改下吗,谢谢,代码如下.
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>后台中心</title>
</head>
<body style="width:96%;margin:auto;">
<div class="panel panel-default">
<table class="text-center table table-bordered table-hover table-striped">
<thead>
<tr>
<th class="text-center" >ID</th>
<th class="text-center">A</th>
<th class="text-center">B</th>
</tr>
</thead>
<script type="text/javascript">
function getIpPlace(obj) {
var script = document.createElement("script");
var _ip = obj.innerHTML;
script.type = "text/javascript";
script.src = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip='+_ip;
document.body.appendChild(script);
{obj.innerText=remote_ip_info["province"] + "省" +remote_ip_info["city"] + "市"}
}</script>
<tr>
<td>0</td>
<td><a href="javascript:void(0)" onclick="getIpPlace(this)">222.88.88.88</a></td>
<td><a href="javascript:void(0)" onclick="getIpPlace(this)">218.28.28.28</a></td>
</tr>
</table>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>后台中心</title>
</head>
<body style="width:96%;margin:auto;">
<div class="panel panel-default">
<table class="text-center table table-bordered table-hover table-striped">
<thead>
<tr>
<th class="text-center" >ID</th>
<th class="text-center">A</th>
<th class="text-center">B</th>
</tr>
</thead>
<script type="text/javascript">
function getIpPlace(obj) {
var script = document.createElement("script");
var _ip = obj.innerHTML;
script.type = "text/javascript";
script.src = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip='+_ip;
document.body.appendChild(script);
{obj.innerText=remote_ip_info["province"] + "省" +remote_ip_info["city"] + "市"}
}</script>
<tr>
<td>0</td>
<td><a href="javascript:void(0)" onclick="getIpPlace(this)">222.88.88.88</a></td>
<td><a href="javascript:void(0)" onclick="getIpPlace(this)">218.28.28.28</a></td>
</tr>
</table>
</div>
</body>
</html>