+ 1
How does I add ID to the parameter
as the code shown below: https://code.sololearn.com/WyJoZ6wKcZ15/?ref=app
11 Answers
+ 3
You could use dataset attribute, eg.
<button class="btn" data-id="a">A button</button>
<button class="btn" data-id="b">B button</button>
in JavaScript, you could get the data attribute by
const el = document.querySelectorAll('.btn');
alert(el[0].dataset.id); // output 'a'
alert(el[1].dataset.id); // output 'b'
+ 1
Could it be possible you use a variable which does not exist? The variable letters is not declared somewhere
+ 1
thank you so much
+ 1
thank you . i try to use target.id or event.target instead .
0
thanks in advance ,for helping me in my school project
0
You wanna add an id to what?
0
add the id of the alphabet button to the function name call check(letter)
0
You mean the ID should be the parameter?
0
yup
0
No problem:)
0
I'd suggest to use a real IDE such as Webstorm,which Highlights mistakes like this.