Home > Back-end >  Select option change css
Select option change css

Time:01-15

how can I change the css of another element when I click any option in the select option Note : The data comes from the database into the select option

CodePudding user response:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="type">
    <option value="item0">--Select an Item--</option>
    <option value="item1">item1</option>
    <option value="item2">item2</option>
    <option value="item3">item3</option>
</select>

<select id="size">
    <option value="">-- select one -- </option>
</select>

CodePudding user response:

You can do that in javascript,

const yourSelector = document.getElementById('yourSelector');
yourSelector.addEventListener('change', () => 
   document.querySelector(yourAwesomeElement).style..... // whatever you want
)

this code will change the css of another element when you will click on any option of the selector.

  •  Tags:  
  • Related