0

Lets say that I have this simple link with data inside:

<a href="#" data-value="Something" onclick="testFunction(this)">X</a>

How can I access this data-value using JavaScript or jQuery.

I tried this but didn't work:

function testFunction(element){
    console.log(element.value);
}

or this

function testFunction(element){
    console.log(element.data('value'));
}

Any help?

2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.