Created
November 9, 2018 18:17
-
-
Save leonidaswander/d5b5600da08a3a05834f3e8a68c20ec1 to your computer and use it in GitHub Desktop.
Capturar atributo de um Select Option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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