我想知道每个玩家是否具有不活跃或 longinactive 状态,如果有,请点击绿眼:(见第3张图片)
眼睛图标,即icon.icon_eye.hueRotate
然后,我尝试了一些像这样的代码:
if(td.playername.js_playerName6.longinactive) {
// code to be executed if condition is true
console.log('OK');
}
else {
// code to be executed if condition is false
console.log('FUCK');}
但我收到了这个错误:
然后我尝试了这个:
$("tr:contains('playername.js_playerName3.longinactive')" ).css( "display", "none" );
以防万一,我想在td或tr中改变一些东西,因为如果它有效,我可能想出一种方法来修改我想要完成的东西。
顺便说一下,我的主要问题是我不知道如何处理表行或列。玩家3的完整代码(我相信所有内容都相同,但名称更改除外)
<tr class="row inactive_filter
">
<td class="position js_no_action ">3</td>
<td rel="planet3" class="tooltipRel
tooltipClose
tooltipRight
js_hideTipOnMobile
microplanet
js_planet3
colonized
" data-planet-id="34478246" colspan="1">
<div class="ListImage">
<a href="javascript: void(0);" onclick="sendShips(
6,
1,
465,
3,
1,
20
); return false;">
<img class="planetTooltip dry_9" src="https://gf2.geo.gfsrv.net/cdndf/3e567d6f16d040326c7a0ea29a4f41.gif" alt="" height="33" width="38">
</a>
</div>
<div id="ownFleetStatus_3_1" class="fleetAction">
<img src="https://gf2.geo.gfsrv.net/cdndf/3e567d6f16d040326c7a0ea29a4f41.gif" width="12" height="12" alt="">
</div>
<div id="planet3" style="display: none;" class="htmlTooltip galaxyTooltip">
<h1>Planeta: <span class="textNormal">MAHOU</span></h1>
<div class="splitLine"></div>
<ul class="ListImage">
<li><span id="pos-planet">[1:465:3]</span></li>
<li><img class="planetTooltip dry_9" src="https://gf2.geo.gfsrv.net/cdndf/3e567d6f16d040326c7a0ea29a4f41.gif" alt="" height="33" width="38"></li>
</ul>
<ul class="ListLinks">
<li><a href="javascript:void(0);" onclick="sendShips(6,1,465,3,1,20);return false">Espionaje</a></li><li><a href="https://s106-es.ogame.gameforge.com/game/index.php?page=messages&ajax=1&messageId=27425792&tabid=20" class="overlay">Informe de espionaje</a></li><li><a href="https://s106-es.ogame.gameforge.com/game/index.php?page=fleet1&galaxy=1&system=465&position=3&type=1&mission=1">Atacar</a></li><li><a href="https://s106-es.ogame.gameforge.com/game/index.php?page=fleet1&galaxy=1&system=465&position=3&type=1&mission=3">Transporte</a></li>
</ul>
</div>
</td>
<td class="planetname ">
MAHOU
</td>
<td class="moon js_moon3 js_no_action">
<div id="ownFleetStatus_3_3" class="fleetAction">
<img src="https://gf2.geo.gfsrv.net/cdndf/3e567d6f16d040326c7a0ea29a4f41.gif" width="12" height="12" alt="">
</div>
</td>
<td class="debris js_debris3 ">
<div id="ownFleetStatus_3_2" class="fleetAction">
<img src="https://gf2.geo.gfsrv.net/cdndf/3e567d6f16d040326c7a0ea29a4f41.gif" width="12" height="12" alt="">
</div>
</td>
<td class="playername
js_playerName3
longinactive
">
<a href="javascript: void(0);" class="tooltipRel tooltipClose tooltipRight js_hideTipOnMobile" rel="player148501">
<span class="status_abbr_longinactive">KAISER</span>
</a>
<span class="status">
(<span class="status_abbr_longinactive"><span class="status_abbr_longinactive tooltip js_hideTipOnMobile" title="Inactivo 28 días">I</span></span>)
</span>
<div id="player148501" style="display: none;" class="htmlTooltip galaxyTooltip">
<h1>Jugadores: <span>KAISER</span></h1>
<div class="splitLine"></div>
<ul class="ListLinks">
<li class="rank">Clasificación: <a href="https://s106-es.ogame.gameforge.com/game/index.php?page=highscore&site=20&searchRelId=148501">1933</a></li>
<li><a href="javascript:void(0)" class="sendMail js_openChat tooltip" data-playerid="148501">Escribir mensaje</a></li>
<li><a href="https://s106-es.ogame.gameforge.com/game/index.php?page=buddies&action=7&id=148501&ajax=1" class="overlay" data-overlay-title="Solicitud de amigo a jugador">Solicitud de amigos</a></li>
<li><a href="https://s106-es.ogame.gameforge.com/game/index.php?page=ignorelist&action=1&id=148501">Ignorar jugador</a></li>
</ul>
</div>
</td>
<td class="allytag
js_allyTag3
">
</td>
<td class="action" colspan="2">
<span>
<a class="tooltip js_hideTipOnMobile espionage" title="Espionaje" href="javascript: void(0);" onclick="sendShips(
6,
1,
465,
3,
1,
20
); return false;">
<span class="icon icon_eye hueRotate"></span>
</a>
<a href="javascript:void(0)" class="sendMail js_openChat tooltip" data-playerid="148501" title="Escribir mensaje"><span class="icon icon_chat"></span></a>
<a class="tooltip overlay buddyrequest" title="Enviar solicitud de amigo" href="https://s106-es.ogame.gameforge.com/game/index.php?page=buddies&action=7&id=148501&ajax=1" data-overlay-title="Solicitud de amigo a jugador">
<span class="icon icon_user"></span>
</a>
<span class="tooltip js_hideTipOnMobile overlay missleattack" title="Ataque con misiles" data-overlay-modal="true">
<span class="icon icon_missile grayscale"></span>
</span>
</span>
</td>
</tr>
答案 0 :(得分:1)
要检查元素是否具有类,请执行以下操作:
$('td.playername').hasClass('someclass');
但是在你的情况下,td本身没有一个非活动类或长活动类,它是。 所以在你的情况下你可以这样做:
// this means that try to find a child within td.playername that has a class that we are looking for, and .length means that it is found if is it more than 0 (true)
if ($('td.playername').find('span.inactive, span.longactive').length) {
console.log('found my class');
} else {
console.log(':(');
}
答案 1 :(得分:0)
试试这个我希望这对你有用。
$('body').on('click','.playername',function(){
var result= $(this).closest('tr')
.find('td.playername')
.hasClass('someclass');
if(result) {
// code to be executed if condition is true
console.log('OK');
}
else {
// code to be executed if condition is false
console.log('Not Found');
}
});