Currently, I am working with a bootstrap accordion and attempting to retrieve the ID and HREF values for each individual accordion using jQuery. Here is the code snippet that I have been utilizing:
$('.room-loop').each(function(id){
$('.room-loop-a').attr("href", '#'+(id));
$('.room-loop-body').attr("id", id)
console.log(id)
});
However, upon execution, the ID and HREF attributes for all elements with the classes "room-loop-a" and "room-loop-body" are set to 3. Various attempts such as importing a variable ID and incrementing it within the loop have been made, but none of them seem to be effective in resolving the issue. Are there any suggestions or solutions that could potentially address this problem?