1

I would like to apply a css file after choosing an option from a html <select> tag.

I tried to use these links to existing css files.

<link rel="stylesheet" href="first.css" />
<link rel="stylesheet" href="second.css" />

How can I use them in <select>?

    <select name="choose-an-option">
        <option value="first">
                            <!--use first.css here-->
        </option>
        <option value="second">
                            <!--use second.css here-->
        </option>
    </select>
Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
Lgn
  • 9,581
  • 5
  • 20
  • 26

2 Answers2

3

You may want to look at this

pollirrata
  • 5,188
  • 2
  • 32
  • 50
2

Try this:

$("#choose-an-option").change(function() {
    $("link").attr("href", this.value + ".css");
)};
Ram
  • 143,282
  • 16
  • 168
  • 197