jquery - Use a javascript variable with .attr() value -
i want use javascript variable .attr() value
my code :
var nombre_pv = 18; var nombre_pv_max = 20; var pv_enlever = nombre_pv_max - nombre_pv ; var pv = nombre_pv_max - pv_enlever; var pv = pv/nombre_pv_max; var pv = pv * 100; $(".hp").attr("value", "/* insert pv here*/");
$(".hp").val(pv);
or
$(".hp").prop("value", pv);
you might want check out answer explain why value
attribute on element not same property: https://stackoverflow.com/a/5876747/779323
Comments
Post a Comment