javascript - emulating mouse clicks on a series of a tags -


I am trying to set up the link in an array so that I have:

 < Code> & lt; A href = "#" onClick = "JavaScript: Functionality ();" Name = "mylinks" & gt; Link1 & lt; / A & gt; & Lt; A href = "#" onClick = "javascript: doFunction ();" Name = "mylinks" & gt; Link2 & lt; / A & gt; & Lt; A href = "#" onClick = "javascript: doFunction ();" Name = "mylinks" & gt; Link3 & lt; / A & gt; ...  

And I want JavaScript to use the array like this:

  function doAll (var {, i = l = document. For mylinks.length; (i = 0; i  

However when I execute doAll So, it tells me that document.mylinks.length is zero or not an object. What is the correct way to do this?

First, use dom to get your anchor elements

  

To emmulate an onclick and you should create and send a dummy event (if supported)

  function doClick (link) {if (document.createEvent) {var Evt = document.createEvent ("MouseEvents"); Evt.initMouseEvent ("click", true, true, window, 0, 0, 0, 0, false, false, false, false, 0, zero); Link.dispatchEvent (evt); } And if (link.click) link.click (); }  

then put it together:

  var links = document.getElementById ("linkContainer"). ChildNodes; (Var l = 0; l  

I have tested this, which works.


Comments

Popular posts from this blog

iphone - How do I make a UIPickerView in a UIActionSheet -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -