Move elements with javascript

Solved
OlegSIAP
Tourist
4 1 0

Hello!

I want to move a FAQ element inside another element (in this case inside a div), using javascript. 

I add in theme.liquid a script with javascript code, I selected the element that I want to move and the element that will content., en moved it with appendChild.

No changes in the interface. Can you help me with this solution? 

My code:

<script>
      var faq = document.getElementsByClassName("section-faq");
        var cont = document.getElementsByClassName("product_form");
        cont.appendChild(faq);
  </script>
 
Thank you!
Accepted Solution (1)

Accepted Solutions
OlegSIAP
Tourist
4 1 0

This is an accepted solution.

Hello!

I already did. 

Thank you for your help!

View solution in original post

Replies 5 (5)
sktch-io
Tourist
6 0 3

Can you share a link to the page you're working on (with the code you quoted), that will help us figure out the issue.

Sktch.io Theme Builder: Create Shopify themes without writing a single line of code!
OlegSIAP
Tourist
4 1 0

Thank you for your answer!

Link: https://bm5eorh2q6ckllo1-55085793316.shopifypreview.com/products_preview?preview_key=e01e7dfcfd91048...

In the bottom there is a FAQ section. I want to move after the button "buy it now"... I want to have the the effect for close an open the text, because my product description is very long and I don't like how render it.

 

Thank you!

LitCommerce
Trailblazer
257 61 67

Hi @OlegSIAP,

I really don't understand your following request, where are you trying to move it? https://i.imgur.com/Bp1Rpg3.png

Please send me a screenshot with description on it. I will check it.

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
OlegSIAP
Tourist
4 1 0

This is an accepted solution.

Hello!

I already did. 

Thank you for your help!

View solution in original post

sktch-io
Tourist
6 0 3

You can try something like this and see if it works:

<script>
$(".product_form").append($(".section-faq"));
</script>

Sktch.io Theme Builder: Create Shopify themes without writing a single line of code!