+ 2
I am trying to make the function give the paragraph the text....
...only if the last 2 letters of the a string are the same as the first 2 letters of the input value. I can't make it work. Help https://code.sololearn.com/WWjpi4z61zwH/?ref=app
7 Answers
+ 3
change event listener from "change" to "keyup"
+ 2
Event for that is 'input' not 'change'
Change is for radio buttons, checkboxes or dropdowns.
+ 2
Wait, I just checked again and it works with change too. I think my mistake was, that I begun the word with Cd and not cd
+ 1
but what are you trying to achive, given the string is "abcd" and if we type any string it matches the last two characters i.e. "cd" then only the <p> tag will get the text, but it is its actual implementation?
+ 1
Sami Khan It seems to work with the keyup event, but I want the event to run only when I press enter in the input, that is why i used change event.