Good day! Im a newbie. Im trying to add image in the option tag in the select. but when i run the code. It doesnt show the image. can someone help me? thank you
This is the code:
HTML:
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Custom select box Jquery Plugin by VJ</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div class="selected-item">
<p>You Selected Country : <span>Select</span></p>
</div>
<select name="" id="cusSelectbox">
<option value="Select">Select</option>
<option value="India"><img src="https://static.webshopapp.com/shops/094414/files/054959460/the-united-states-flag-icon-free-download.jpg">India</option>
<option value="Nepal">Nepal</option>
</select>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
It's Difficult to Customize
<select>
&<option>
Tags<select>
and<option>
tags are difficult to customize and anything that holds true for one browser is never true for the rest of them.Solution
<select>
, create a pseudo-<select>
✱ using<details>
and<summary>
<select>
<details>
&<summary>
<option>
, create a pseudo-<option>
✱ using<input type='radio'>
and<label>
<option>
<input type='radio'>
&<label>
✱The pseudo-
<select>
and pseudo-<option>
tags will be close in appearance and behavior to that of the standard<select>
and<option>
tags. More importantly, it can store and process avalue
, and it can be registered to thechange
event.Demo
Details are commented in demo