I am attempting to store html code in a textarea field using jquery with the following code:
var text ="<p>Hello, my name is Sam</p>";
var textarea = d.createElement( 'textarea' ); // Creates textarea to store text
div.appendChild( textarea );
textarea.innerHTML = text;
// $("textarea").val(modified_clipboard_text); // same issue
console.log( textarea.innerHTML ); // output should not be escaped html
The issue is, html strings are transformed to escaped entities (at least in Chrome). For example: <p>
is transformed to <p>
JQuery solution
You're using jquery so why not using the magic :
var text ="<p>Hello, my name is Sam</p>";
$('#container').append('<textarea></textarea>');
$('#container textarea').val(text);
$('#select-btn').click(function() {
$('#container textarea').select();
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='container'></div>
</br>
<button id='select-btn'>Select</button>
I have this multi dimensional array of objects - const initialArray = [ { name: 'aaa', value:[{id:1, data:1}, {id:2, data:2}, {id:3, data:3}] }, { name: 'bbb', value:[{id:1, data:...
I have this multi dimensional array of objects - const initialArray = [ { name: 'aaa', value:[{id:1, data:1}, {id:2, data:2}, {id:3, data:3}] }, { name: 'bbb', value:[{id:1, data:...
Let's say I have a number input with only a few possible values like the following : <label for="test" translate="entities.test"></label> <input id="test" name="test" type="number" min=...
Let's say I have a number input with only a few possible values like the following : <label for="test" translate="entities.test"></label> <input id="test" name="test" type="number" min=...
I am trying to write postgre puppet AST query in java script/coffee script, but I am not able to figure out how to send data (curl -d) through a GET request in java/coffree scripts. Can anyone help? ...
I am trying to write postgre puppet AST query in java script/coffee script, but I am not able to figure out how to send data (curl -d) through a GET request in java/coffree scripts. Can anyone help? ...
How can I get the option in a dropdownlist based off of the value that is selected? Essentially I want to get the option that is selected and then change the innerHTML. Here is what I have so far.. ...
How can I get the option in a dropdownlist based off of the value that is selected? Essentially I want to get the option that is selected and then change the innerHTML. Here is what I have so far.. ...