$('#types').change(function() {
var htmlToAppend = "<br/><input id='btnAddDictionary' type='button' value='Add Dictionary' />";
if ($("#types").val() == 'enumType') {
$(this).append(htmlToAppend); //problem is in there
debugger;
}
else {
//removebutton or not show it
}
});
views:
22answers:
1
+1
A:
Try this:
$('#types').change(function() {
var htmlToAppend = "<br/><input id='btnAddDictionary' type='button' value='Add Dictionary' />";
if ($(this).val() == 'enumType') {
$(this).after(htmlToAppend);
debugger;
}
else {
$(this).next('br').remove();
$(this).next('#btnAddDictionary').remove();
}
});
Nick Craver
2010-03-03 17:37:00
$(this).append(htmlToAppend); problem is there. he appends after enumType value, but not after select box
loviji
2010-03-03 17:39:14
@loviji - Clarify what you mean by "after select box"?
Nick Craver
2010-03-03 17:40:37
I mean: add html button element after html SELECT element.<select id="types" ><option value="int">integer</option><option value="enumType">enumerable</option><input id='btnAddDictionary' type='button' value='Add Dictionary' /></select>
loviji
2010-03-03 17:41:43
@loviji - Oh right, duh...fixed in answer, use `.after()` not `.append()`
Nick Craver
2010-03-03 17:42:59