This is the code:
<div class="sampletext" contenteditable="true" style="min-height: 40px;">
<span></span>
</div>
What I'm trying to do is filling an element with keypress
events.
<div class="sampletext" contenteditable="true" style="min-height: 40px;">
<span>i need to fill here with keyboard events. {ENTER}</span>
</div>
I have write a basic function which fills the innerHtml,
function myFunction()
{
var element = document.getElementsByClassName('sampletext')[0].firstChild;
element.innerHTML = 'i need to fill here with keyboard events.\n';
}
Basically this function will do the job, but it won't work in the site which am trying. If am entering it from keyboard it works perfectly. The window is listening for the keyenter
event.
I'm using Chrome browser. The project was related with the cefsharp.
private void SampleFucntion()
{
string script = "var element = document.getElementsByClassName('sampletext')[0].firstChild;element.innerHTML = 'i need to fill here with keyboardevents.\n';";
myBrowser.ExecuteScriptAsync(script);
}
I already checked input fill with keypress simulation
So please help me how can I achieve this with pure JavaScript.