Check out this fiddle I created: http://jsfiddle.net/4Ly1973u/.
Below is the HTML code I used:
<article>
<select>
<option name='First' value='first'>First</option>
<option name='Second' value='second'>Second</option>
<option name='Third' value='third'>Third</option>
</select>
<div data-name='first' class='show'>
This one should show by default.
</div>
<div data-name='second'>
only visible when "second" option is selected
</div>
<div data-name='third'>
only visible when "third" option is selected
</div>
</article>
My goal is to have the first div displayed by default, and dynamically switch to the corresponding div based on the select option chosen. While I could achieve this with an if statement, considering a scenario where there are multiple options, I am exploring cleaner alternatives. Is there any other approach apart from using if statements?