繁体   English   中英

加载页面时会出现一个文本框,即使我已将其“样式:显示”设置为无

[英]A text box appears when I load the page even though I have set its “style:display” to none

<input type="text" name="otherPONumber" id="otherPONumber" maxlength="25" style="display: none;">


<script type="text/javascript">
function toggleField(val) {
    var obj = document.getElementById('otherPONumber');
        if(obj != undefined && txt != undefined) {
        (val == 'Other')? obj.style.display = 'block' : obj.style.display = 'none';

    }
}

</script>

尽管如此,当页面加载时会出现文本框。

(val == 'Other')? obj.style.display = 'block' : obj.style.display = 'none';

这种对三元运算符的滥用是可怕的。 将其替换为以下内容:

obj.style.display = (val == 'Other') ? 'block' : 'none';

如果元素在加载后立即显示,请使用 Firefox(或类似工具)检查是否有一些 CSS 规则覆盖了您的内联样式。

为什么这个 tetx 没有在 x 轴上溢出,即使我有一个固定的宽度和<p tag is set to display: block?< div></p><div id="text_translate"><p> 我需要文本在 X 轴上溢出只是为了重现我在更大项目中遇到的一些问题。 我留下一个简单的片段,所以你可以告诉我我在哪里做错了。 谢谢! </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> .article { background-color: rgb(236, 161, 161); width: 20em; }.article p { display: block; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;article class="article"&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Perferendis deleniti iure quidem distinctio officia voluptates similique molestiae culpa? Perferendis, velit maiores nobis maxime aut facere eaque quis voluptas accusamus commodi.&lt;/p&gt; &lt;/article&gt;</pre></div></div><p></p></div>

[英]why is this tetx not overflowing on the x axis even though I have a fixed width and the <p tag is set to display: block?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使我在react / redux中使用受保护的路由设置了身份验证,我仍保持注销状态? 当我刷新页面时 为什么这个 tetx 没有在 x 轴上溢出,即使我有一个固定的宽度和<p tag is set to display: block?< div></p><div id="text_translate"><p> 我需要文本在 X 轴上溢出只是为了重现我在更大项目中遇到的一些问题。 我留下一个简单的片段,所以你可以告诉我我在哪里做错了。 谢谢! </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> .article { background-color: rgb(236, 161, 161); width: 20em; }.article p { display: block; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;article class="article"&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Perferendis deleniti iure quidem distinctio officia voluptates similique molestiae culpa? Perferendis, velit maiores nobis maxime aut facere eaque quis voluptas accusamus commodi.&lt;/p&gt; &lt;/article&gt;</pre></div></div><p></p></div> 为什么我将 css 中的 div 的无显示应用于其所有后代,即使我将其中一个后代设置为显示块? 如何检查有关display:none style的文本内容 即使在代码中更改了元素,也无法在将其显示设置为无后重新显示元素 在页面加载时显示具有样式显示的div:无 需要将1个span的样式设置为display ::由span的set设置为display:none的图库在页面加载时被阻止 datatables:即使列具有“ display:none”样式,该列也会显示在“显示/隐藏列”列表中 尽管我将其设置为使用javascript不显示,但下拉菜单中的第一个选项已全部修复 仍然以“显示:无”样式显示Div
 
粤ICP备18138465号  © 2020-2023 STACKOOM.COM