answersLogoWhite

0

What is innerHTML in javascript?

Updated: 8/10/2023
User Avatar

Wiki User

11y ago

Best Answer

innerHTML is often used in javasript to change the value already present in html tags. For eg The following code will change the text on button click

<html>

<head>

<script type="text/javascript">

function changeText()

{

document.getElementById("changeText").innerHTML = "I am fine thank you. How about you?"

}

</script>

</head>

<body>

<div id="changeText">

Hello! How are you?

</div>

<input type="button" value="Change Text" id="button_1" onclick="changeText()" />

</body>

</html>

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Inner HTML would be the text between two tags,

en example of the Inner HTML of bold text would be:

<b>Inner Html is Right Here</b>

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is innerHTML in javascript?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you show the text box output in the browser using Ajax code?

You can directly do that in the JavaScript. Just get the value of the input type in JavaScript using id and show it using .innerHTML.


How do you add text to an already existing p tag in JavaScript or PHP?

Consider your HTML &lt;p id="pid"&gt;Hello &lt;/p&gt; In javascript document.getElementById('pid').innerHTML="world"; Remember "id" are unique on the HTML page hence js will always pick &lt;p&gt; where id=pid.


Is there a way to edit the information received coming from a javascrpt website. Like an online roulette game so you win all the time with javascript?

If it's written in JavaScript...maybe you could edit variables so that you'd win. I know that if there is a plug in to the .innerHTML of the site, you can exploit that so you can make links that can edit vars. But I'm not sure about your site.


What is HTML code of Display text after click on submit button?

To create a button that displays text after being clicked, you can use HTML and JavaScript. Here's an example code: HTML: &lt;button onclick=&quot;displayText()&quot;&gt;Submit&lt;/button&gt; &lt;p id=&quot;text&quot;&gt;&lt;/p&gt; JavaScript: function displayText() { document.getElementById(&quot;text&quot;).innerHTML = &quot;Text to display after clicking submit button.&quot;; } In this code, the button is created using the &lt;button&gt; tag and an onclick attribute is added to call the displayText() function when clicked. The function displayText() uses JavaScript to access the element with the ID &quot;text&quot; and change its innerHTML to the desired text, which will be displayed below the button.


How do you create a JavaScript program to calculate 1 plus 3 plus 5 plus 7 plus to 1023?

&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; var n, tally = 0; for(n = 1; n &lt;= 1023; n += 2){ tally += n; } document.getElementByID('output').innerHTML = 'the tally is ' + tally; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="output"&gt; &lt;/div&gt; &lt;/body&gt;


What is the command to display HTML page through javascript?

If you're planning on linking to another page, all you have to write is: document.location = "yourNewURL"; If you want to generate Javascript, then you can either use: document.write("your HTML Code"); OR send the HTML code to an existing object in an HTML page, like so: document.getElementById['targetElement'].innerHTML = "your HTML Code here"; ----------------- That's pretty much it. If you want me to elaborate, please let me know. :)


How do you display 22 plus 32 plus 42 plus 52 equals 54 in javascript?

document.getElementById('outputdiv').innerHTML = '22 + 32 + 42 + 52 = 54'; or perhaps: alert('22 + 32 + 42 + 52 = 54'); You really couldn't do any calculations to display that, as the statement itself is false.


What is a javascript tutorial?

A JavaScript tutorial contains instructions that will teach you how to code in JavaScript.


What languages can a browser understand?

HTML, CSS, &amp; JavaScript.


What are built-in javascript classes?

Javascript does not have classes


How do you sort in javascript?

Javascript can help in browseing


How old is Javascript?

Javascript was created in 1995.