improve inefficient jQuery selector

后端 未结 2 782
遥遥无期
遥遥无期 2021-02-08 14:58

In IntelliJ, if I use a jQuery selector such as:

$(\'#roleField option\').each(function() {
    // impl omitted
});

The selector is highlighted

2条回答
  •  故里飘歌
    2021-02-08 15:39

    Try to use .find() here:

    $('#roleField').find('option').each(function() {
        // impl omitted
    });
    

    Your warning seem like related to efficiency of the selector.

    Related thread

提交回复
热议问题