I have a series of divs that have similar ids with the exception of a unique # at the end (cartbtn0, cartbtn1, etc.). I have created one generic function that will work across all the divs using a wildcard, but I need to be able to capture the unique # of the div that was clicked in order to replace the 0 in #cartbox0:hidden. Can anyone please help?
Sample code:
$("*[class^=cartbtn]").click(function () {
$(this).hide();
$('#cartbox0:hidden').fadeIn(2000);
});
<div id="cartbtn0" class="cartbtn0">.....</div>
<div id="cartbox0>" class="cartbox0" style="display:none;">.....<div>
<div id="cartbtn1" class="cartbtn1">Text</div>
<div id="cartbox1>" class="cartbox1" style="display:none;">Text<div>