Reputation: 5
I have this line in my JS
document.getElementById("divtry").innerHTML = jsdat;
divtry is my div in HTML and I want the content which will be displayed inside that div (the content will be different from jsdat as the special characters like <br>
and other special characters will be converted to HTML equivalent. Ex: <br>
will be converted to <br>
)
My problem is not yet solved. my Input is this string.
asd <br>sp
I need the output as below.
asd
sp
I am getting the output as below now.
asd <br> sp
I tried the below code.
document.getElementById("output").innerHTML = jsdat;
var jsfin = document.getElementById("output").innerHTML;
document.getElementById("o1").value = jsfin;
Output & o1 are my 2 div. But I am getting correct output in output while in o1 I'm getting the input text intself.
So, my question is, how can I get the contents inside that div divtry and assign it to some variable. Can someone please give me a function which will do that.
Upvotes: 0
Views: 1115
Reputation: 2904
Did you try anything before asking this question?
jsdat = document.getElementById("divtry").innerHTML;
Upvotes: 3