The function parameter of jquery .val() returns the function as a string
<p>As part of an onClick event, the value of each of the clicked row's subsequent siblings' hidden "sequence" inputs is reduced by one.</p>

<pre><code>$('#variants_' + product + ' .sequence')
    .filter(function(){
        return parseInt(this.value, 10) &gt; sequence;
    })
    .val(function(index, value){
        return value - 1;
    });
</code></pre>

<p>The inputs I'm trying to change end up looking like this:</p>

<pre><code>&lt;input type="hidden" name="v_sequence_6" id="v_sequence_6" value="function (index, value){
                    return value - 1;
                    }" class="sequence"&gt;
</code></pre>

<p>How can I use the function parameter of .val() without it being turned into a string?</p>

<p><strong>edit</strong>
here's the rest of the relevant function</p>

<pre><code>function deleteVariant(row, product) {
var x = /x/
var sequence = $('#variantRow_' + row + ' .sequence').val();
if (! x.test(row) ){
    $('#variants_' + product).closest('#variants').append("&lt;div class='grayover'&gt;&lt;div class='ajaxLoaderContainer'&gt;&lt;div class='ajaxLoader'&gt;&lt;img src='images/ajax-loader.gif' /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;");

    $.post('includes/_e-learning_ajax.php', { 'mode': 'deleteVar', 'variant': row }, function(data){
        if (data == 'success'){
            $('#variants_' + product + ' .sequence')
                .filter(function(){
                    return parseInt(this.value, 10) &gt; sequence;
                    })
                .val(function(index, value){
                    return value - 1;
                    });
            $('#variantRow_' + row).remove();
            coursesReady();
        } else {
            alert(data);
        }
        $('.grayover').remove();
    });

} else {
    $('#variantRow_' + row).remove();
}
}
</code></pre>
