简体   繁体   中英

How to change property of field while redirecting to same page

I have a js page in my react app where I have one calendar div and I'm showing one popup card with one close button.

If I click that button then it should redirect to me to the same page with calendar div open.

I'm using window.history.back() to redirect to the same page only and it's working but how can I make that div display.

What you would normally do is, after doing:
window.history.back() , you do something like
document.querySelectorAll('.calendar-div')[0].classList.add('show');

This would add a .show class to the calendar-div element. If you're using a third party plugin, this would be explained in their docs, but for this instance, you would then add something like this to your css

.calendar-div{
   opacity:0; // let us say you are using this to introduce the div in the redirect
}
.calendar-div.active{
   opacity:1;
}

With the minimalist question, this is what I can deduce as the suitable answer, you can update your question or add a comment in my answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM