Reputation: 5010
I am trying to get a specific id by clicking on a button that can be anywhere on the page.
I am trying as follows:
$(document).on('click','.cia_delete',function(e){
e.preventDefault();
e.stopPropagation();
let thisBtn = $(this);
let refreshArea = thisBtn.closest("body").find("#cia_refresh_area");
});
In the above code, I want to find #cia_refresh_area
that can be anywhere in the document.
Is the above code correct?
Upvotes: 0
Views: 64
Reputation: 17190
Based on the feedbacks of your question, your code should be like this:
$(".cia_delete").click(function(e)
{
e.preventDefault();
e.stopPropagation();
let refreshArea = $("#cia_refresh_area");
});
Anyways, I suggest you to read more about the JQuery selectors. Like a basic example related to the code:
Upvotes: 2