How to get text value from child elements?
Let's say I have this code on the page:
<div class='geshitop'>
[ CODE ] [ <a href="#" onclick="javascript:copy(); return false;">PLAIN-TEXT</a> ]
</div>
<div class='geshimain'>
<pre><div class="text" style="font-family:monospace;">Code goes here...</div></pre>
</div>
Function copy():
<script type="text/javascript">
function copy() {
var text = this.parent.getElementsByName("text");
var code = text[0].value;
var popup = window.open("", "window", "resizeable,width=400,height=300");
popup.document.write("<textarea name='code' cols='40' rows='15'></textarea>");
popup.code.value = code;
}
How can I get the data from this child element: <div class "text">. How can I get this from a parent?
I'm still having problems. If there are two code blocks on one page, this will not work. Remember, I cannot use identifiers. These should be classes.
If I could use jQuery, that would be easy.
source
share