I have a page that contains multiple, identical hidden forms, each contained in a separate hidden DIV as such:
HTML:
<div class="product-intro-text">Some text....
<div class="rfq-button"><a class="advantage-button" id="Adapters" href="#">Request a Quote</a></div>
<div class="inline-rfq">
<form class="contact" name="contact" action="#" method="post">...</form>
</div>
</div>
<div class="h-sep"></div>
<div class="product-intro-text">Some text....
<div class="rfq-button"><a class="advantage-button" id="Auger Equipment" href="#">Request a Quote</a></div>
<div class="inline-rfq">
<form class="contact" name="contact" action="#" method="post">...</form>
</div>
</div>
Instead of having all of these identical hidden DIVs, how can I reposition the .inline-RFQ DIV to appear below the corresponding .rfq-button that was clicked? This is for a mobile site, so solutions would have to be mobile-friendly.
I'm already using JS/JQuery throughout the rest of the page and here is the JS that reveals the hidden DIV:
jQuery(document).ready(function($){
/* toggle form */
$(".rfq-button").on("click", function(){
$(this).next().slideToggle();
$(".inline-rfq").next().toggleClass("display");
});
});
Thanks for your help in advance.
Here's a fiddle: http://jsfiddle.net/psyon001/ejdgX/ One thing you may want to add is reseting the form states when showing under a new section.
jQuery(document).ready(function($) { /* toggle form */
$(".rfq-button").on("click", function() {
var $thisParent = $(this).closest('.product-intro-text'),
$form = $(".inline-rfq");
if ($thisParent.find('.inline-rfq').length) {
$form.slideToggle();
} else {
$form.slideUp(function() {
$form.appendTo($thisParent).slideDown();
});
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With