Here is my code:
$('#mySelect').on('change', function() {
var value = $(this).val();
$(".title").html(value);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="icon"><i class="fa fa-check-square"></i>
<span class="title"> Title </span>
<br /><br />
<select id="mySelect">
<option value="" selected disabled hidden>Choose a social media</option>
<option value="Telegram" >Telegram</option>
<option value="Instagram">Instagram</option>
<option value="Facebook">Facebook</option>
<option value="GooglePlus">GooglePlus</option>
</select>
All I'm trying to do is also changing that icon. I mean I have an array contains needed class names:
var classes = {Telegram: "fa-telegram", Instagram: "fa-instagram", Facebook: "fa-facebook-square", GooglePlus: "fa-google-plus-square"};
I want to change the class of that i
(which is into span.icon
) based on the selected option. How can I achieve this?