Created
November 20, 2018 22:34
-
-
Save leonidaswander/79f4caca28084d6d1b1a18a946fdc444 to your computer and use it in GitHub Desktop.
Revisions
-
leonidaswander renamed this gist
Nov 20, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
leonidaswander created this gist
Nov 20, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.js"></script> <label for="brand">Bandeira do Cartão</label> <select id="frm_brand" required style="width:100%;"> <option value="" selected>Selecione um bandeira</option> <option value="visa">Visa</option> <option value="mastercard">MasterCard</option> <option value="jcb">JCB</option> <option value="diners">Diners</option> <option value="amex">Amex</option> <option value="elo">Elo</option> <option value="aura">Aura</option> </select> <script> function formatState (state) { if (!state.id) { return state.text; } var baseUrl = "img"; //Na pasta em questão adicione as imagens. Cada imagem deverá ter o nome igual ao value correspodente no option var $state = $( '<span><img src="' + baseUrl + '/' + state.element.value.toLowerCase() + '.png" class="img-flag" /> ' + state.text + '</span>' ); return $state; }; $("#frm_brand").select2({ templateResult: formatState }); </script> <style> .img-flag { width:25px } </style>