js if class exists copy contents into div code example
Example: check class exist in element by parent id in jquery
$(this).parent().find('.accordion-body').length == 1;
or you can use hasClass()
$(this).parent().find('.accordion-body').length == 1;
or you can use hasClass()