Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
How to modify html document inside div in jquery?

How I can modify HTML document inside my div in jQuery?

This is my code:

$(".lastName").click(function() {
  val = $(".mydiv").clone();
  //then before to append the 'val' in result class, i want it first to modify the label text from 'First Name' to 'Last Name'
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="mydiv">
  <label class="label">First Name</label>
  <input type="text" class="myinput">
</div>
<div class="result"></div>
<button class="lastName">Last Name</button

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

With html(), but first get the node with .find('.label') and print in result $('.result').html(val)

$(".lastName").click(function() {
  let val = $(".mydiv").clone();
  $(val).find('.label').html('Last Name');
  //then before to append the 'val' in result class, i want it first to modify the label text from 'First Name' to 'Last Name'
  $('.result').html(val)
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<div class="mydiv">
  <label class="label">First Name</label>
  <input type="text" class="myinput">
</div>
<div class="result"></div>
<button class="lastName">Last Name</button>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!