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

323
Views
Cómo insertar un valor de elemento, usando jQuery, en un cuadro de alerta

Estoy tratando de agregar el elemento Fuerte al cuadro de alerta en este escenario. Sin embargo, está devolviendo "indefinido".

¿Puede alguien decirme dónde me equivoqué con mi sintaxis aquí? Gracias

 $('.copyURL').click(function(e) { e.preventDefault(); let ele = $(this).parent().siblings(':first-child').children(); let label = $(this).parent().parent().siblings(':first-child').children(); ele[0].select(); ele[0].setSelectionRange(0, 99999); navigator.clipboard.writeText(ele[0].value); alert(label[0].value + "\r\n" + "\r\n" + "Copied: " + ele[0].value + "\r\n" + "\r\n" + "Use this link for your WEB site"); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div> <label> <strong>Copy This Strong Label Into Alert</strong> </label> <div class="row collapse"> <div class="columns small-7"> <input type="text" value="<#servername>/<#Database_Name>/<#business_business>/gift" readonly> </div> <div class="columns small-2"> <a class="button full-width" href="./<#business_business>/gift" target="_blank">View</a> </div> <div class="columns small-3"> <a class="button full-width secondary copyURL"><i class="far fa-clone"></i> Copy URL</a> </div> </div> </div>

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

0

Debe usar textContent para obtener el texto del elemento strong , no el value :

 $('.copyURL').click(function(e) { e.preventDefault(); let ele = $(this).parent().siblings(':first-child').children(); let label = $(this).parent().parent().siblings(':first-child').children(); ele[0].select(); ele[0].setSelectionRange(0, 99999); navigator.clipboard.writeText(ele[0].value); alert(label[0].textContent + "\r\n" + "\r\n" + "Copied: " + ele[0].value + "\r\n" + "\r\n" + "Use this link for your WEB site"); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div> <label> <strong>Copy This Strong Label Into Alert</strong> </label> <div class="row collapse"> <div class="columns small-7"> <input type="text" value="<#servername>/<#Database_Name>/<#business_business>/gift" readonly> </div> <div class="columns small-2"> <a class="button full-width" href="./<#business_business>/gift" target="_blank">View</a> </div> <div class="columns small-3"> <a class="button full-width secondary copyURL"><i class="far fa-clone"></i> Copy URL</a> </div> </div> </div>

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!