How to select label for=“XYZ” in CSS?

后端 未结 3 1880
忘掉有多难
忘掉有多难 2020-11-28 01:36

HTML:

CSS:

label {
  display: block;         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 02:08

    If the content is a variable, it will be necessary to concatenate it with quotation marks. It worked for me. Like this:

    itemSelected(id: number){
        console.log('label contains', document.querySelector("label[for='" + id + "']"));
    }
    

提交回复
热议问题