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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -