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

128
Views
jQuery custom attr no funciona en la etiqueta de opción

He seleccionado el tipo con attr personalizado en la etiqueta de opción. Cuando puedo obtener el valor, pero no puedo obtener el valor en el atributo personalizado.

Aquí está Jsfiddle

JSFDDLE

 <script> jQuery(document).on('change','.selectedItem',function() { var selectedValue = jQuery(this).val(); alert(selectedValue); alert(jQuery(this).attr("id")); var product_id = jQuery(this).attr('rel-product-id'); alert(product_id); var product_name= jQuery(this).attr("rel-product-name"); alert(product_name); }); </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Entonces, el problema es que está tratando de obtener los valores de los atributos de la select en sí. Lo que desea hacer es obtenerlos de la opción seleccionada de la option de uso select option:selected . Como esto:

 alert(jQuery('option:selected', this).attr('id')); alert(jQuery('option:selected', this).attr('rel-product-id')); alert(jQuery('option:selected', this).attr('rel-product-name'));
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!