I think the problem is because you are setting value to a div
. Although use of val
works, this function is primarily used on form elements such as input
, select
and textarea
.
If you mean to replace the content of the div.te-len
then you could use either html
or text
:
$('.te-len').html( data[selected].length )
But it sounds like you are trying to show data[selected].length
value in the input.exerciseLength
numeric field. For that you should be using:
$('#exercise_length').val( data[selected].length )