I'm trying to add an onclick event with JavaScript.
$.getJSON(api , function(data) {
//First Option found (not working)
//document.getElementById("today_button").SetAttrribute("onclick", "window.location.replace('" + data[1] + "')");
//Second Option found (not working either)
document.getElementById('today_button').onclick = "window.location.replace('" + data[1] + "');";
});
The Variables exist, the Event is fired, the data transmitted are correct and everything except this works just fine (like altering the disabled state of exactly this button).
I hope you can help me