I'm trying to call the setVideo()
function on click event. But when it is embedded in html, it gets executed right away because of the brackets. Is inline-style the only way to do it?
<script>
window.onload = rv_clicked;
function rv_clicked() {
var v_links = document.querySelectorAll("#recommendation img");
for (var i = 0; i < v_links.length; i++) {
// this gets executed right away:
v_links[i].onclick = setVideo(v_links[i].title);
}
}
</script>