Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
How to dynamically change themes after clicking a drop down menu of themes with vanilla javascript

enter image description hereI'm using bootstrap for the interface of the website I'm developing. I am also planning to integrate the bootswatch themes to my site. I have created a dropdown menu containing the different themes of bootswatch. My problem is how can I switch themes when I click one of the themes in the dropdown menu? Note that I want to do this with raw JavaScript without any special framework

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Set your link with an id:

<link rel="stylesheet" id="dynamicCSS" type="text/css" href="mystyle1.css" />

Apply an onchange event to your select list:

<select id="myDropdownList" onchange="swapCSS()">
  <option>mystyle1.css</option>
  <option>mystyle2.css</option>
  <option>mystyle3.css</option>
</select>

Add your Javascript function:

const swapCSS = function()
{
  let selection = document.getElementById("myDropdownList").selectedOptions[0];
  document.getElementById("dynamicCSS").href = selection.value;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!