Jess McKenzie Jess McKenzie - 7 months ago 11
Javascript Question

Percentage of values changed in a textarea

A)

.originalData
is a textarea

B)
.changedData
is also a textarea but this is were I will be making the changes

How could I calculate a percentage of the values changed in B starting at 0%?

jQuery:

var changed, original = $(".originalData").val() $(".changedData").change(function(){ changed = $(this).val(); });

Answer

if you want to calculate the percent of changes i guess you have to do something like this

var changedData = $('.changedData').val().length;
var originalData = $('.changedData').val().length;

var precentageOfChange = changedData/originalData * 100 - 100
$('.mydiv').append(precentageOfChange);