jQuery addClass example

Change class name on click in jQuery

HTML

<br>
<input type="text" placeholder="title" id="choose_title" />
<br>
<input type="text" placeholder="#000000" id="color" />
<br>
<label><input type="checkbox" id="bold"> Bold</label>
<br>
<textarea id="title_name" rows="5" placeholder="Result"></textarea>
<br>
<input type="submit" name="action3" id="update_rez" value="Generate" />

JavaScript

$(document).ready(function() {
    $('#update_rez').click(function() {
        var toInsert = "<font color='" + $('#color').val() + " '>" + $('#choose_title').val() + "</font>";

        if ($('#bold').is(':checked'))
            toInsert = "<b>" + toInsert + "</b>"

        $('textarea').val(toInsert);
    });
})