【问题标题】:Force browser to display Element as text强制浏览器将元素显示为文本
【发布时间】:2019-06-03 22:24:58
【问题描述】:

我遇到了这个奇怪的问题: 我得到动态构建的内容。在这种特殊情况下,我还将元素“输入”作为内容,然后浏览器将其作为元素直接显示。

我得到了什么:

<div class="search_result_content"> this is just text, but the code <input variable="" name=""> displays as an element

我需要什么:

【问题讨论】:

标签: css html web browser


【解决方案1】:

你可能想添加'type="text"',所以总数会像

<input type="text" name="" value=""/>

如果输入需要添加到(如)'span' 或 'div',我建议使用 JS 或 jQuery

【讨论】:

    【解决方案2】:

    $(document).ready(function() {
      $(".search_result_content").append('<input variable="" name="">');
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <div class="search_result_content"> this is just text, but the code  </div>

    这种场景下动态插入输入标签,插入后转换成html格式

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 2018-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多