Javascript 我如何做:href="#id1,id2;?
我有生成特定按钮的代码:Javascript 我如何做:href="#id1,id2;?,javascript,jquery,html,onclick,href,Javascript,Jquery,Html,Onclick,Href,我有生成特定按钮的代码: let layerPill = document.createElement('a'); layerPill.setAttribute("data-toggle", "pill"); layerPill.setAttribute("href", `#layer${numOfLayers[layersCreated]}`); layerPill.setAttribute("onclick", `getStreamNContentLoca
let layerPill = document.createElement('a');
layerPill.setAttribute("data-toggle", "pill");
layerPill.setAttribute("href", `#layer${numOfLayers[layersCreated]}`);
layerPill.setAttribute("onclick", `getStreamNContentLocale('layer${numOfLayers[layersCreated]}-container', 'head${numOfLayers[layersCreated]}-container', '${stream}', '${numOfLayers[layersCreated]}', '${platform}', '${drm}')`);
layerPill.innerHTML = `layer ${numOfLayers[layersCreated]}`;
过去,我只需要在href=“#layer[number]”中使用它
,其中具有该ID的元素如下所示:
<div class="tab-pane fade active in" id="layer1">
<div class="tab-pane fade" id="layer2">
<div class="tab-pane fade" id="layer3">
<div class="tab-pane fade active in" id="head1">
<div class="tab-pane fade" id="head2">
<div class="tab-pane fade" id="head3">
并且,使它们的id相同不会使选项卡窗格褪色
工作,但html页面上的第一个除外
现在我可以很容易地添加另一个类似于layerPill的元素,专门用于新元素,并在我单击任何一个pill时使其生效,它们也会单击相邻的另一个pill,但我不希望有办法在没有它的情况下使其生效