I'm trying to make a script that gets the class .data from the input and convert the date to pt-br, but I can not do it, I'd like some help.
$.fn.converteData = function(){
var data = ($(this).val()).split("-");
var dataf = data[2]+data[1]+data[0];
$(this).val(dataf);
$(this).mask("99/99/9999"); //estou usando o plugin maskedinput
}
$(".data").converteData();
<form>
<label for="dt_nasc">Data de nascimento</label>
<input class="data" name="dt_nasc" type="text" value="1966-11-27">
</form>
I wanted it to already be called automatically for all html inputs with the .data class. I get her in 1966-11-27 this script would be to convert 27/11/1966.