I want a link, when clicked, to execute a javascript function.
Here is the javascript:
<script type="text/javascript">
function changeStyle() {
var header = document.getElementbyId("header");
var container = document.getElementbyId("container");
header.style.display = "block";
container.style.marginLeft = "auto";
}
</script>
Here is the HTML:
<a href="javascript:changeStyle()"><span>☰</span> MENU</a>
Currently, when the link is clicked, nothing happens. How would I make it so that the javascript actually changes the styles when I want it to?
EDIT:
Here is new code:
Javascript:
$('#selector').click(function() {
var header = document.getElementById("header");
var container = document.getElementById("container");
header.style.display = "block";
container.style.marginLeft = "auto";
})
HTML:
<a href="#" id="selector"><span>☰</span> MENU</a>