I have to enter a random value in a textarea
of a web site by using grease monkey script the text area didn\'t have an id
so document.getElementB
You could use element.querySelector if you want to be able to specifically target an element using a CSS selector, similar to this:
var textArea = document.querySelector('table tr td.pd5 textarea.msgbox');
textArea.value = "My Random Text";
The above is working on the following HTML example:
Message
140 characters max.
DEMO - Using element.querySelector
Off course, you can now change the CSS selector to anything you like to match your DOM hierarchy. There is lots of flexibility using element.querySelector
.