Skip to content
Advertisement

How do I check if I have selected the same drop-down list option twice in a row?

Let’s supose I have a simple drop-down list from which I can freely select any option I want.

I can, via JavaScript, store the selected option’s value in a variable this way:

JavaScript
JavaScript

Questions:

  1. How can I check if I have selected the same drop-down list option twice in a row, in other words, if the value of currentValue has changed?

  2. Would using AngularJS make this task easier? How?

Advertisement

Answer

JavaScript
JavaScript
Advertisement