This is relevant to this problem (which has been solved): Previous Problem:Solved, just to give context to the question.
What I want to do is to apply the link that I've got from the previous code, into a href in a button element. This is what I've got so far:
<script type="text/javascript">
var newestLink = "";
window.setTimeout(function(){
var newLink = $('.link:last').attr("href");
newestLink = newLink;
}, 1500);
window.setTimeout(function(){
alert(newestLink);
document.getElementById('#redButton').onClick = function() {
document.getElementById('#redButton').href=newestLink;
}
}, 3000);
</script>
The alert
code is just to check that I have the correct value. When I use this code, the console return an error Uncaught TypeError: Cannot set property 'onClick' of null (anonymous function)
I can't seem to understand where the code gone wrong. I'm following this advise.