/    Sign up×
Community /Pin to ProfileBookmark

Show/hide partucular div – how-to?

Hi, can you help me to find what I am doing wrong?

I want to have a particular div hidden by default and show it after clicking on “Finish the order”.

My HTML:
<h4 class=”order-toggle” onclick=”showOrderForm”>Finish the order</h4>
<div id=”order-form-hidden”> …here is the order form… </div>
…and the script added:
<script type=”text/javascript” src=”show_hide_order_form.js”></script>

CSS:
.order-toggle {
display: block;
cursor: pointer;
}
#order-form-hidden {
display: none;
}

Javascript:
function showOrderForm() {
var x = document.getElementById(“order-form-hidden”);
if (x.style.display === “none”) {
x.style.display = “block”;
} else {
x.style.display = “none”;
}
}
I also tried it in this way:
function showOrderForm() {
$(“#order-form-hidden”).toggle();
}

It does not work.
I made another script for something else, added it in the same way, and it works properly.
I also tried not to hide the div element by default, it did not help.
I have no more ideas… Thanks for help 🙂

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@daveyerwinSep 22.2020 — you forgot the parenthesis

&lt;h4 class="order-toggle" onclick="showOrderForm()"&gt;Finish the order&lt;/h4&gt;
Copy linkTweet thisAlerts:
@HarshShahSep 24.2020 — @Lucyova#1623523

Please refer the below link their give full details about hidden and show.

[https://www.geeksforgeeks.org/hide-or-show-elements-in-html-using-display-property/#:~:text=To%20hide%20an%20element%2C%20set,style.](url)
×

Success!

Help @Lucyova spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,
)...