Reputation: 57
I want to display the text using display property in css
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
Upvotes: 0
Views: 574
Reputation: 72289
1. You have to use .innerHTML
like below:
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
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:
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
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>
Upvotes: 2