Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  10] [ 2]  / answers: 1 / hits: 5668  / 9 Years ago, mon, july 13, 2015, 12:00:00

My divs are not showing when I click on submit.



I can get them to show if I do a window.onload() but the divs have to have display: none; by default;



How can I make it so these divs show when I hit submit because my form takes about 30 seconds to process, it has a lot of fields.



HTML



<div id=overlay-back></div>
<div id=overlay>
<div id=dvLoading>
<p>Please wait<br>while we are loading...</p>
<img id=loading-image src=img/ajax-loader.gif alt=Loading... />
</div>
</div>


Submit Button



  <div class=form-buttons-wrapper>
<button id=submit name=submit type=submit class=form-submit-button>
Submit
</button>
</div>


CSS



#overlay {
position : absolute;
top : 0;
left : 0;
width : 100%;
height : 100%;
z-index : 995;
display : none;
}
#overlay-back {
position : absolute;
top : 0;
left : 0;
width : 100%;
height : 100%;
background : #000;
opacity : 0.6;
filter : alpha(opacity=60);
z-index : 990;
display : none;
}
#dvLoading {
padding: 20px;
background-color: #fff;
border-radius: 10px;
height: 150px;
width: 250px;
position: fixed;
z-index: 1000;
left: 50%;
top: 50%;
margin: -125px 0 0 -125px;
text-align: center;
display: none;
}


jQuery



<script>
$(function() {
$('#submit').on('submit', function() {
$('#dvLoading, #overlay, #overlay-back').prop(display, block).fadeIn(500);
});
});
</script>


The reason I am displaying none by default in css because if someone has javascript disabled I do not want any inteference


More From » jquery

 Answers
1

Try this:



<script>
$(function() {
$('#submit').on('click', function(evt) {
evt.preventDefault();
$('#dvLoading, #overlay, #overlay-back').fadeIn(500);
});
});
</script>


The fadeIn will make the div visible.



.prop sets the properties of the element, not the style.



  • Changed to use the click event


[#35667] Friday, July 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bryantc

Total Points: 455
Total Questions: 96
Total Answers: 110

Location: San Marino
Member since Thu, Jun 30, 2022
2 Years ago
bryantc questions
Fri, Aug 13, 21, 00:00, 3 Years ago
Tue, Mar 30, 21, 00:00, 3 Years ago
Fri, Jun 5, 20, 00:00, 4 Years ago
Wed, May 27, 20, 00:00, 4 Years ago
;