html - Javascript not being called from hyperlink -


I am using Google Apps Script to create a web app that includes many hyperlinks when clicking on hyperlinks Then it is considered to trigger a warning box (it is just the filler code to see if the JS function is being called). This hyperlink is being generated using this JavaScript function:

  Function Update Alternate (results) {var div = document.getElementById ('Output'); Div.innerHTML = ''; (Var i = 0; i & lt; results.length; i ++) {div.innerHTML + = '& lt; P & gt; & Lt; One class = "ra-button" href = "javascript: zero (0)" onclick = "myJsFunc ()" & gt; '+ Result [i] .alertName +' & lt; / A & gt; & Lt; / P & gt; '; }}   

and JS function which generates the warning:

  function myJsFunc () {Warning ('This function was called'); }   

For some reason, only the final hyperlink in the list of hyperlinks will trigger the JJ function, named Mikefenk. Whenever I click on any other hyperlink that is first in the list, then the JS function is not called. When I look at the console in Chrome Developer Tools, then I think "why does the hyperlink work in my list of hyperlinks?" Anybody know that "property can not be read" plugin_despechevate ___'s "undefined"

I will change my code to:

  function Update Allist (results) {var div = document.getElementById ('Output'); div.innerHTML = ''; var alrtInnrHTML = ''; (Var i = 0; i & lt; results.length; i ++) {alrtInnrHTML = '<
>> l Urg = "ra-button" href = "javascript: zero (0)" onclick = "myJsFunc ()" & gt; '+ result [i] .alertName +'

Please note that I have a variable alrtInnrHTML , And using the + = on the variable, not the internal HTML. You are trying to use + = on DOM manipulation instead of a variable Set the first HTML text string, then inject the entire string just once. Now you are adding HTML again more often to the same DIV. Will all the links appear? In any case, if your argument is working, I will also change the argument I am suggesting, check that the final HTML content console.log () is correct with the output, And then inject the HTML one at a time.

You actually have individual & lt; P & gt; and and lt; A & gt; by adding tags, and adding HTML instead of trying to build HTML string in each loop.

You want to read something:

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -