简体   繁体   中英

javascript onclick slide div down instead of remove?

I am using the following code inside my div element so when a user clicks on the link within the div the div is hidden/removed.

However, is there a way I could use the same one line of code that I am using to remove the div but instead get it to slide down to hide?

$_SESSION['password_change'] = '<div id="bottom_notification" onclick="this.parentNode.parentNode.removeChild(this.parentNode);"><div id="bottom_notification_heading"><h23>Password Change!</h23><div class="boxclose" id="boxclose">&#10006;</div></div><p>Hi, your accessing your account for the first time, so we recommend you change your password.</p><p><a href="process/change_pass.php" rel="shadowbox;height=300;width=470">Click Here</a></p></div>';

ontopic

A short answer to your question would be no, you can't, not with that one line. Javascript does not have a default method for sliding things or animating things at all. This all has to be written by the developer.

If you don't know how to write such things or don't know any javascript I'd recommend jQuery as a library for now but do know that if you use jQuery it's better to understand the JS behind it as well. (jQuery = a set of JS functions made for you eg library)

jQuery website

offtopic

It's also quite weird to store chunks of a page in a php session as this is not what it's made for.

sessions are used for saving small pieces of data or objects through page reloads / navigation through pages, in your case I would reconsider the use of PHP sessions to not store HTML but rather find a different solution to displaying the div on your page.

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