如果select.value = enumType,则在复选框按钮后追加

时间:2010-03-03 17:35:15

标签: jquery

      $('#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
            }
        });

1 个答案:

答案 0 :(得分:1)

试试这个:

  $('#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();
        }
  });