There are times tha i feel so frustrated when trying to do simple things with Jquery. I have a textarea where user can write own things but can also chose from some predefined phrases and add them too
so html looks like
<textarea id="id_text"></textarea>
<div id="predef-phrases>
<input type="checkbox"><label>checkbox1</label>
<input type="checkbox"><label>checkbox2</label>
<input type="checkbox"><label>checkbox3</label>
<input type="checkbox"><label>checkbox4</label>
</div>
<input type="button" id="add" name="add" value="Add phrases" />
and the jquery is like this:
$(document).read(function(){
$("#add").click(function(){
$("#predef-phrases input[type=checkbox").each(function(i, checkbox){
if($(checkbox).is(":checked")){
text_value = $("#id_text").val();
checkbox_text = $(checkbox).next('label').text();
$("#id_text").append(checkbox_text+'\n');
}
});
});
});
Everything works fine up until the user types some text. Then the predefined phrases are not appended in textarea when user presses the add button. Am i missing something?