Reputation: 39250
I would like to select all the text in a contenteditable div when a button is clicked. Kind of like
document.getElementById("myTextArea").select()
I've looked into creating a range but that isn't visible to the user.
Is there a way to do this in JavaScript (using closure library)?
Upvotes: 0
Views: 111
Reputation: 1857
I'm sorry I did not understand what do you want
function highlight(element){
var inner = document.getElementById(element).innerText;
inner = "<span class=\"highlighted\">" + inner + "</span>"
}
<style>
span .highlighted{
background-color: yellow;
}
<style>
Upvotes: 1
Reputation: 1857
var x = document.getElementById("myTextArea").innerText;
this line to get the content of any thing has an id
document.getElementById("myTextArea").innerText = x;
this line to set the content
now put that code in a function and call it onClick like this
<input type="submit" onClick="functionname();" id="submit">
Upvotes: 0