<p>I have two elements:</p>

<pre><code>&lt;input a&gt;
&lt;input b onclick="..."&gt;
</code></pre>

<p>When b is clicked, I want to access a and manipulate some of its data. A does not have a globally unique name, so <code>document.getElementsByName</code> is out. Looking into the event object, I thought <code>event.target.parentNode</code> would have some function like <code>getElementsByName</code>, but this does not seem to be the case with &lt;td&gt;s. Is there any simple way to do this?</p>

[{'answer_id': 53261, 'author': '17 of 26', 'author_id': 2284, 'author_profile': 'https://Stackoverflow.com/users/2284', 'pm_score': 4, 'selected': True, 'text': '<p>If <code>a</code> and <code>b</code> are next to each other and have the same parent, you can use the <code>prevSibling</code> property of <code>b</code> to find <code>a</code>.</p>\n'}, {'answer_id': 53262, 'author': 'Joseph Pecoraro', 'author_id': 792, 'author_profile': 'https://Stackoverflow.com/users/792', 'pm_score': 2, 'selected': False, 'text': '<ol>\n<li><p>You should be able to find the element that was clicked from the <a href="http://www.w3schools.com/htmldom/dom_obj_event.asp" rel="nofollow noreferrer">event object</a>.  Depending on your browser you might want <code>e.target</code> or <code>e.srcElement</code>. The code below is from this <a href="http://www.w3schools.com/js/tryit.asp?filename=try_dom_event_srcelement" rel="nofollow noreferrer">w3schools example</a>:</p>\n\n<pre><code>function whichElement(e) {\n  var targ;\n  if (!e) var e = window.event;\n  if (e.target) {\n    targ=e.target;\n  } else if (e.srcElement) {\n    targ = e.srcElement;\n  }\n\n  if (targ.nodeType==3) { // defeat Safari bug \n    targ = targ.parentNode;\n  }\n\n  var tname;\n  tname = targ.tagName;\n  alert("You clicked on a " + tname + " element.");\n}\n</code></pre></li>\n<li><p>You may then use the <code>nextSibling</code> and <code>prevSibling</code> DOM traversal functions.  <a href="http://www.newearthonline.co.uk/index.php?page=article&amp;article=284" rel="nofollow noreferrer">Some more information here</a>.  And yet again a w3schools reference for <a href="http://www.w3schools.com/DOM/dom_node.asp" rel="nofollow noreferrer">XML DOM Nodes</a>.</p></li>\n</ol>\n'}, {'answer_id': 53274, 'author': 'rp.', 'author_id': 2536, 'author_profile': 'https://Stackoverflow.com/users/2536', 'pm_score': 0, 'selected': False, 'text': '<p>Leave your plain vanilla JavaScript behind. Get JQuery--it will save you a ton of time.</p>\n\n<p><a href="http://docs.jquery.com/Selectors" rel="nofollow noreferrer">http://docs.jquery.com/Selectors</a></p>\n'}, {'answer_id': 53536, 'author': 'ujh', 'author_id': 4936, 'author_profile': 'https://Stackoverflow.com/users/4936', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype</a> also has nice functions to move around in the DOM. In your example something like the following would do the trick:</p>\n\n<pre><code>b.up().down(\'a\')\n</code></pre>\n\n<p>And if there are is more than one a element at that level you have the power of CSS selectors at your hand to specify exactly which element you want</p>\n'}]
['https://Stackoverflow.com/questions/53256', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/429/']