What I have is a class of table rows that, when one of them is clicked, activates a function in jQuery capturing the id of the element that was clicked. I have seen several posts on how to do this (i.e Getting the ID of the element that fired an event or JavaScript - onClick to get the ID of the clicked button), but none of them have worked for me.
So, I thought that this would work:
$(".yourStockTabs").click(function() {
    if (sellStockClicked === true) {
        var ids = $(this).attr("id");
        alert(ids);
    }
});
But it does not. The sellStockClicked === true part is the checker to make sure that a button has already been previously clicked. I figured at first maybe the code to get the attribute was incorrect or maybe the variable wasn't true, but I found that neither of these were the case because I removed the if function and commented out the id part and just had it alert something, but it still did not.
Here is the full code:
$("#sellStockButton").click(function() {
    var sellStockClicked = true;
    alert("Please click on the row of the stock that you would like to sell.\n\nWhen you are finished, click this button again.");
    $(".yourStockTabs").css("background", "#E50000");
    $(".yourStockTabs").css("cursor", "pointer");
});
$(".yourStockTabs").click(function() {
    if (sellStockClicked === true) {
        var ids = $(this).attr("id");
        alert(ids);
    }
});
$("#sellStockButton").click(function() {
    if (sellStockClicked === true) {
       var sellStockClicked = false; 
    }
});
 
     
    