How to get clicked anchor tag value in javascript

This is a list representation of data which is coming from a php database.The list is fetched using a foreach php loop and the data inside the achor tag is populated accordingly.


 
****

As you can see here, inside the anchor tag i have href-ed it to a modal box which will show a message whenever the user clicks on any of the link. There is a button in the modal window which will take the user to a different page. The issue is that i want to pass certain value along with the url, but cannot do so as the link to the next page is defined in the modal window specification part. So i came up with this solution. I thought of using the id attribute of the anchor tag, I tried to get the id attribute of the anchor which was clicked using javascript.


 function theFunction[]
 {
    var id = $['a', this].attr['id'];
    alert[id];
 }

From this i wanted to initialize a php variable and then use that php variable to pass as value in the href of the modal window button. But the value i am getting in the alert box is 'undefined' for some reason. I have tried all possible combinations of this.

$['a',this].attr['id'];
$this.id;

Everything return 'undefined'.

Reference-This is the code for the modal window part.

×

Instructions

Your test is about to commence. A timer will be initiated after the moment you start the test. You may choose to answer a question, or leave it empty. You can also attempt the questions in any order that you find suitable.

Upon completion of the test, click on "Submit" to see your performance statistics.


Good luck!
Close

Chủ Đề