我正在尝试使用parseInt从我的Google Chrome扩展程序中确定span元素是否等于或大于1。
Here is a screenshot of the "inspect" option from within chrome.
这是HTML页面:
<div id="onlinebar" style="text-align: right">
<a href="javascript:win1()" class="tb_options" title="Kalbėkis su savo piratais.">Užsuk į smuklę</a> |
<span id="tb_gang" class="tb_options" onClick="ShowTbPopup(this); obShowHide(0)">My Fleet: (<b>2</b>)</span> |
<span id="tb_friend" class="tb_options" onClick="ShowTbPopup(this); obShowHide(1)">My Friends: (<b>2</b>)</span> |
<span id="tb_enemies" class="tb_options" onClick="ShowTbPopup(this); obShowHide(2)">My Enemies: (<b>0</b>)</span>
<a id="closebox" href="#" onclick="javascript:var conf = confirm('Are you sure you want to remove the login box? (It can be turned back on from settings)'); if(conf){ document.getElementById('onlinebar').style.display='none'; setBarPrefs('11769'); }" style="margin-right:20px;"><img src="/images/close.gif" border="0"/></a>
</div>
这是我尝试过的:
function checkEnemies(){
numEnemies = parseInt($$("[id^=tb_enemies]")[0].title.split(" ")[0]);
if (numEnemies >= 1){
$$("a[href*='sea']")[0].click();
return true;
}
return false;
}
var bool = checkEnemies();
还有这个:
function checkEnemies(){
numEnemies = parseInt($$('#tb_enemies')[0].title.split(" ")[0]);
if (numMessages >= 1){
$$("a[href*='sea']")[0].click();
return true;
}
return false;
}
var bool = checkEnemies();
感谢您提供的任何帮助。
-Shane