【问题标题】:ampersand in the option value in html selectionhtml选择中选项值中的与号
【发布时间】:2016-08-05 08:39:07
【问题描述】:

你知道为什么我在选项值中加上 & 号没有正确呈现

option(value="John & Ken") John & Ken

我已经把它放在选项值上,但它没有显示出来。这是正确的还是我遗漏了什么?

【问题讨论】:

    标签: html special-characters ampersand


    【解决方案1】:

    你到底想做什么?

    如果您使用 JavaScript 将选项元素添加到选择元素,则无需使用 HTML 实体 $amp; 来添加到文本中。

    var select = document.getElementById('myselect'),
    option = document.createElement('option');
    option.innerHTML = "John & Ken";
    option.value = "John & Ken";
    select.add(option);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-16
      • 1970-01-01
      • 1970-01-01
      • 2021-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多