Hi I am stuck on this error for a while and can't seem to find where the problem comes from... I am basically dynamically making multiple list items with buttons in them for each row in my database with 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>
And then check if it has that class I append to it when the upgrade is already bought on each button click with 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");
}
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.