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

132
Views
Get value of select label html via custom attr

I want to know how to get with jquery with method val() the selected value of a select tag through a custom attribute inside it.

Example:

<select dta-tble="table1" onchange="printTable(event);">
var datatable = $(evt.target).attr("**dta-tble**");

var row = $(**..this the solution..**).val();

Thanks.

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

0

try:

var value = $('select[**dta-tble**="table1"]').val();

I recomand you don't use ** characters on html attributed, use example data-table="table1" or id="table1" and you can get value more easly

about 4 years ago · Juan Pablo Isaza Report

0

If you're using jQuery, dont use inline event handlers. You can target elements using the attribute selector

$("select[dta-tble]").on("change", function(){
    const val = $(this).val();
    console.log(val);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select dta-tble="table1">
  <option>1</options>
  <option>2</options>
  <option>3</options>
</select>

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!