I’m trying to show a span with a specific id but it does not seem to work like this.
What am I doing wrong?
This is my code:
“`
// PHP
$xclass = “cart-check:”. $row[‘ID’];
// HTML
<span
id=”<?php echo $xclass; ?>”
style=”display: none;”>
<i class=”fas fa-check”></i> Added!
</span>
<button
type=”button”
class=”btn btn-sm bg-teal”
onclick=”AddCartItem(<?php echo $row[‘ID’]; ?>,'<?php echo $xclass; ?>’)”
>
<i class=”fas fa-cart-plus”></i>
</button>
// JAVASCRIPT
function AddCartItem(ItemID, Xclass) {
jQuery.ajax({
url: “cart_handler.php”,
data: { ItemID },
type: “POST”,
success:function(data){
document.getElementById(Xclass).show(); // <— This line is not working
$(“#user-availability-statusx”).show();
$(“#user-availability-statusx”).html(data);
},
error:function (){}
});
}