gpt4 book ai didi

javascript - 未捕获的类型错误 : undefined is not a function :/

转载 作者:行者123 更新时间:2023-12-03 11:33:19 24 4
gpt4 key购买 nike

嗨,我被这个错误困扰了一段时间,似乎无法找到问题出在哪里......我基本上是使用 php 动态地为数据库中的每一行创建多个带有按钮的列表项:

<div id="upgrades">
<ul>
<?php
for($i=0;$i<count($_SESSION['upgrades']);$i++)
{
$class = '';
if($_SESSION['upgrades'][$i]['gekocht'] == TRUE)
{
$class = 'gekocht';
}
echo '
<li>
<button class="upgradebutton'.$class.'" data-id="'.$_SESSION['upgrades'][$i]['update_id'].'">'.$_SESSION['upgrades'][$i]['naam'].'</button>
</li>';
}
?>
</ul>
</div>

然后检查它是否具有我在使用 javascript 单击每个按钮时已购买升级时附加的类:

$(document).ready(function(){   
$('.upgradebutton').click(function(){
if(!$(this).hassClass('upgradebuttongekocht'))
{
var upgrade_id = $(this).attr("data-id");
alert(upgrade_id);
$(this).addClass('gekocht');
window.upgrades[upgrade_id][gekocht] = 1;
}else{
alert("already Bought");
}
});
});

最佳答案

只需使用 hasClass 而不是 hassClass

http://api.jquery.com/hasclass/

:)

关于javascript - 未捕获的类型错误 : undefined is not a function :/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26647930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com