TonYem
TonYem

Reputation: 51

jQuery appending elements from a class

I'm trying to write a jQuery code that will append a text from 'projects-content' class into the '.projects-text' (instead of appending "hello world" paragraph)

$(".projects-carousel .owl-nav").click(function(){
       $('.projects-text').append('<p>Hello world</p>'
)
   });
<div class="projects-Wrapper">
  <div class="projects-content">
  <h3> This header should append in projects-text div </h3>
  <p>This is the text should append in projects-text div as well</p>
  </div>
    <div class="projects-img-wrapper">
    <a class="popup-youtube" href="#"><img src="img/projects/1.png" alt="Jey The Dog"></a>
  </div>
</div>

  <div class="projects-text"> 
   
   <!-- Here should a text from ".projects-content" append -->
  
  </div>

.

Upvotes: 0

Views: 25

Answers (1)

Agam Banga
Agam Banga

Reputation: 2693

You can use the method html of jquery to get & set the html content. It will include the HTML tags. If you want to get the text only, you can use the text method. Replace this

$('.projects-text').append('<p>Hello world</p>');

to

$('.projects-text').html($('.projects-content').html());

Upvotes: 1

Related Questions