Skip to content

Instantly share code, notes, and snippets.

@leonidaswander
Created November 9, 2018 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonidaswander/d5b5600da08a3a05834f3e8a68c20ec1 to your computer and use it in GitHub Desktop.
Save leonidaswander/d5b5600da08a3a05834f3e8a68c20ec1 to your computer and use it in GitHub Desktop.
Capturar atributo de um Select Option
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<select class="form-control" name="frm_select" id="frm_select">
<option value="1" atributo_nome="Primeiro Item" >
Item 1
</option>
<option value="2" atributo_nome="Segundo Item" >
Item 2
</option>
</select>
<script>
$("#frm_select").change(function()
{
var atributo_nome = $('option:selected', this).attr('atributo_nome');
//alert(atributo_nome);
console.log(atributo_nome);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment