img.onclick = function() { // old fashioned img.src = "sth.jpg"; img.alt = "something"; img.title = "some title"; // or the W3C way img.setAttribute("src", "sth.jpg"); img.setAttribute("alt", "something"); img.setAttribute("title", "some title"); };
Note. No matter which one you use, if you are dealing with standard attributes.
galambalazs
source share