Select previous "this" element
<p>I have a piece of javascript code where i am trying to get to the previous element declared. Currently i have two on click functins within eachother.</p>

<pre><code>$('#formIngredient').on("click", '.newIngredient', function() {
    value = $(this).attr('data-name');
    $(this).attr('data-isactive', 'true');

    $('#newIngredientInput').val(value);
    $('#newIngredient').modal('show')

    $('#createNewIngredient').click(function() {
        inputName = $('#newIngredientInput').val();
        inputCategory = $('#newIngredientCategory').val();

        var newIngredient = $.ajax({
            type: "GET",
            url: '/content/includes/ajax/createNewIngredient.php',
            data: {name: inputName, id_category: inputCategory}
        });

        newIngredient.done(function(result) {
            //PAI.showPage(PAI['PAGE']);
            $(this).parent().replaceWith('Hello');
            $('#newIngredient').modal('hide');
        });
    });
});
</code></pre>

<p>I am trying to use the previous element with this code.</p>

<pre><code>$(this).parent().replaceWith('Hello');
</code></pre>

<p>Any ideas?</p>
