const ftop = () => {
const scrollToButton = document.querySelector('.ftop');
const targetElement = document.querySelector('.seared');
scrollToButton.addEventListener('click', function () {
const targetElementRect = targetElement.getBoundingClientRect();
window.scrollTo({
top: targetElementRect.top + window.scrollY,
left: targetElementRect.left + window.scrollX,
behavior: 'smooth'
});
});
}
return(
<div className='seared'>
<div>111</div>
<div>111</div>
<div>111</div>
<div className="ftop"><h2><BackTop onClick={ftop} /></h2></div>
</div>
)