显示选项标签中的div值

时间:2017-03-22 10:36:42

标签: javascript html css option

您好我有以下代码:

const array1 = "Accessories:Bracket,Accessories:Clamp,Actuator:Accessories,Actuator:Accessories:Bracket,Actuator:Accessories:Clamp,Actuator:Clevis".split(
  ","
);
const array2 = "24092859,24092784,24094450,24094451,24110219,24092811".split(
  ","
);

const output = array1.reduce(
  (topLevelNodes, path, i) => {
    let nodes = topLevelNodes;
    let mtdId = array2[i];
    path.split(":").forEach(text => {
      let node = nodes.filter(child => child.text === text)[0];
      if (node) {
        node.mtdId += "," + mtdId;
      } else {
        nodes.push((node = { text, children: [], mtdId }));
      }
      nodes = node.children;
    });
    return topLevelNodes;
  },
  []
);

console.log(output);

现在我想添加显示左侧的代码 h1 id ="教父"在值1,
h1 id =" shawshank"价值2 或者可能是第三个值3

我怎样才能做到这一点? 提前致谢

2 个答案:

答案 0 :(得分:0)

你想要这个吗?希望对你有帮助    



DECLARE
  CURRENT_YEAR VARCHAR2(5);
BEGIN
  SELECT TO_CHAR(SYSDATE,'YYYY') INTO CURRENT_YEAR FROM DUAL;
  RETURN CURRENT_YEAR;
END;

 




答案 1 :(得分:0)

这是代码。据我所知你需要这个

    <html>
<head>
<style>

</style>

</head>
<body>

<div id="left">
<p class="Title"> <h2>MARIO PUZO'S</h2> </p>
<h1 id="godfather"></h1> 

<div class="Txt2">


<select id="1" onclick="test()">
<option value="1" >desk</option>
<option value="2">dark, empty room(shawshank redemption)</option>
<option value ="3">SOCIAL ROOM(fight club)</option></select>
</div>

</body>
<script>
function test() {
            var val= document.getElementById('1').value;

    if (val == '1') {
        document.getElementById('godfather').innerHTML = 'God Father';

    }
    if (val == '2') {
        document.getElementById('godfather').innerHTML = 'shawshank';

    }
    if (val == '3') {
    document.getElementById('godfather').innerHTML = 'Anything Else';
    }
    else{

    }
    }

</script>
</html>