带有jquery的材料设计动态芯片-chipSetEl.appendChild不是函数

带有jquery的材料设计动态芯片-chipSetEl.appendChild不是函数,jquery,css,material-design,md-chip,Jquery,Css,Material Design,Md Chip,我试图在用户从下拉列表中选择选项时添加标记。因此,他们可以选择多个项目,然后将有标签下面展示的选择 我当前的尝试,尝试从以下方面获取: const chipSetEl=mdc.chips.MDCChipSet.attachTo(document.querySelector('.mdc chip set'); //const chipSet=新的mdc.chips.MDCChipSet(chipSetEl); $(函数(){ $(document).on(“change”,#search_sel

我试图在用户从下拉列表中选择选项时添加标记。因此,他们可以选择多个项目,然后将有标签下面展示的选择

我当前的尝试,尝试从以下方面获取:


const chipSetEl=mdc.chips.MDCChipSet.attachTo(document.querySelector('.mdc chip set');
//const chipSet=新的mdc.chips.MDCChipSet(chipSetEl);
$(函数(){
$(document).on(“change”,#search_selectWrap',function(){
const chipEl=document.createElement('div');
//…执行操作以正确填充/装饰芯片元件。。。
chipSetEl.appendChild(chipEl);
//芯片组。添加芯片(芯片组);
});
});
我的错误目前是:

chipSetEl.appendChild不是函数

但是,如果我添加取消注释芯片组初始化,我也会得到错误:

此.root\ querySelectorAll不是函数

芯片组el console.log:

编辑

芯片组的新定义和定制尝试:

const chipSetEl = document.querySelector('.mdc-chip-set');
const chipSet = new mdc.chips.MDCChipSet(chipSetEl);
console.log(chipSetEl);

$(function()
{
    $(document).on("change", '#search_selectWrap',function ()  {
        const chipEl = document.createElement('div');
        chipEl.shouldRemoveOnTrailingIconClick = true;
        chipEl.innerHTML = "hi";
        chipEl.style["background-color"] = "green"; 
        // ... perform operations to properly populate/decorate chip element ...
        chipSetEl.appendChild(chipEl);
        chipSet.addChip(chipEl);
    });
});

@对不起,我对这个完全陌生。我认为我的行是:const-chipSetEl=mdc.chips.MDCChipSet.attachTo(document.querySelector('.mdc-chipset');定义是什么?我没有遗漏任何代码。更确切地说,我遗漏了代码中最重要的部分,从你的评论中可以看出?抱歉,我遗漏了那一行。我的错。但是,无论
attachTo()
返回什么,似乎都没有
appendChild()
函数;其中,
chipSetEl
指的是
document.querySelector('.mdc chip set'),而不是附加到
的结果。同一页上有一个部分,标有“你可能会觉得很有启发性”。
style.backgroundColor=“green”
,但你已经扩展到了新的问题。我怀疑您正在添加的DIV需要添加一个类;文档至少显示了“mdc芯片”。
shouldRemoveOnTrailingIconClick
MDCChip
类的属性,而不是元素;你又把这两件事搞混了,这次是相反的:)。@HereticMonkey谢谢,现在一切都好了:)@Rorymcrossan抱歉,我对这件事完全陌生。我认为我的行是:const-chipSetEl=mdc.chips.MDCChipSet.attachTo(document.querySelector('.mdc-chipset');定义是什么?我没有遗漏任何代码。更确切地说,我遗漏了代码中最重要的部分,从你的评论中可以看出?抱歉,我遗漏了那一行。我的错。但是,无论
attachTo()
返回什么,似乎都没有
appendChild()
函数;其中,
chipSetEl
指的是
document.querySelector('.mdc chip set'),而不是附加到
的结果。同一页上有一个部分,标有“你可能会觉得很有启发性”。
style.backgroundColor=“green”
,但你已经扩展到了新的问题。我怀疑您正在添加的DIV需要添加一个类;文档至少显示了“mdc芯片”。
shouldRemoveOnTrailingIconClick
MDCChip
类的属性,而不是元素;你又把这两件事搞混了,这次正好相反:)。@HereticMonkey谢谢,现在一切都好了:)