简体   繁体   English

如何在CSS中使用显示属性显示文本

[英]How to display text using display property in CSS

I want to display the text using display property in css 我想使用CSS中的display属性显示文本

 echo '<script type="text/javascript">document.getElementById("amt1").style.display= "none";</script>';

I want to display text message instead of display ="none" in amt1 id 我想显示短信而不是在amt1 id中display ="none"

1. You have to use .innerHTML like below: 1.您必须使用.innerHTML如下所示:

echo '<script type="text/javascript">document.getElementById("amt1").innerHTML= "add your message here";</script>';

2. If message is already there and you just want to show that div then change none to block 2.如果消息是现成的,你只是想表明DIV然后更改noneblock

echo '<script type="text/javascript">document.getElementById("amt1").style.display= "block";</script>';

3. if you want to add message dynamically as well as you want to show the div too, then: 3.如果您要动态添加消息以及也要显示div,则:

echo '<script type="text/javascript">
    document.getElementById("amt1").innerHTML= "add your message here";
    document.getElementById("amt1").style.display= "block";
    </script>';

Sample javascript code snippet example to understand how it will work 示例javascript代码段示例以了解其工作方式

 document.getElementById("amt1").innerHTML= "This message added in div through javascript .innerHTML method!!!"; document.getElementById("amt1").style.display= "block"; 
 #amt1 { border: 1px solid grey; font-size: 30px; } 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="amt1" style="display:none;"></div> 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM