The conclusion you came to is the corrected one - you cannot send input to a <div>
tag, that's not how browsers usually work (an exception to the rule is given in "edit 2"). The code exception states it clearly - "Element must be user-editable in order to clear it". Regardless that the div has a class value of "edit-cell" - that just a name chosen by a developer, for illustrative proposed; it does not imply the div will be able to take input.
Most probably the UI used by the application uses this <div>
for stylized presentation of the values set by the user; there is a hidden <input>
element that takes the actual keyboard entries, and a javascript code updates the <div>
with them.
You'll have to find that input tag, and target it for your changes.
edit1: Finding input tags by their values with JS.
Here's how to find the input tag - in the browser, (by hand) set the value to a string that would be unique for the page - for instance, "myMegaSpecialString". Then run the following js in the console:
[...document.getElementsByTagName("input")].forEach(function(el){ if (el.value == "myMegaSpecialString"){console.log(el);} })
It will print the <input>
element(s) that has that "special" value.
edit2: Finding any tags by their values with JS.
According to the discussion in the comments, no <input>
element was found to have this value. As I was rightfully corrected by @Andersson, under special circumstances other elements but input can receive, khm, input - they should have the contenteditable
attribute, and it's inherited from parent elements - e.g. if set on the <body>
tag, you can type over any element in the page.
So - a modified version of the javascript to locate "who holds our value"; thankfully, getElementsByTagName()
supports wildcard for argument - that'll match any element:
[...document.getElementsByTagName("*")].forEach(function(el){ if (el.value == "myMegaSpecialString"){console.log(el);} })
It might be a bit slower - but it must print the element(s) with value
property equal to "myMegaSpecialString".
edit3: Finding any tags by their text content, with JS.
The quest continues - the text you are entering does not turn up in any element's value
property? No problem, let's look for it in the elements textual content.
This might be the case when you are actually editing the content of a <span>
, <div>
or similar tags (fingers crossed... :)).
This is a variation of the previous version - manually set the text to a value that is unique across the page (to limit the output), and run this in the console:
[...document.getElementsByTagName("*")].forEach(function(el){ if (el.textContent.indexOf("myMegaSpecialString") !== -1){console.log(el);} })
, which will (should? might? I'm not certain in anything anymore :D) print in the console all DOM elements which have that string as part of their text.
Breakdown what is what in the javascript, for future changes:
document.getElementsByTagName("*")]
returns a all elements with that tag name as an array; the argument asterisk (*
) - any tag name.
forEach
- a loop over the collection elements, passing each one to the anonymous function in it.
el.textContent
- returns the text content of the node (and its child nodes).
indexOf()
- returns the position of the argument in the string, -1
if it is not present (used indexOf()
vs contains()
for compatibility, the later comes in ES6).
- if the condition returns true,
console.log(el)
will print it in the console.