How do I hijack a link tag and assign a variable with id of a link tag before going to the url? 

MY HTML Code

```
<div id="course" class="row">
    <div class="col-md-6"><a href="read.html" id="m1">Course 1</a></div>
    <div class="col-md-6"><a href="read.html" id="m2">Course 2</a></div>
<div>

```

MY JAVASCRIPT CODE

```
document.getElementById("course").addEventListener("click", courseInfo);

function courseInfo(){

    var selectedCourse = the id of the course selected;

    //assign to localstorage
    localStorage.setItem("courseid", selectedCourse);
    //go to courseinfo.html
    window.location.href = 'courseinfo.html';

}

```

I'm trying to get the Id of the course and the set it to the local storage so that when the courseinfo.html is loaded if will make request ajax and parse the course json format to fill the page.

Please help