Create multiple select box with jQuery
by terby
HTML
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<title>Multiple Select</title>
<style>
* { box-sizing: border-box; }
body {
font-family: Arial, Helvetica, sans-serif;
background: #f5f5f5;
padding: 40px;
}
.ms-wrapper {
position: relative;
width: 280px;
}
.ms-box {
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
padding: 8px 10px;
cursor: pointer;
font-size: 14px;
color: #333;
display: flex;
justify-content: space-between;
align-items: center;
}
.ms-box:hover {
border-color: #999;
}
.ms-arrow {
font-size: 10px;
color: #888;
}
.ms-dropdown {
display: none;
position: absolute;
top: 100%;
left: 0;
right: 0;
margin-top: 4px;
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
max-height: 220px;
overflow-y: auto;
z-index: 10;
}
.ms-dropdown.open {
display: block;
}
.ms-option {
padding: 8px 10px;
font-size: 14px;
color: #333;
display: flex;
align-items: center;
cursor: pointer;
}
.ms-option:hover {
background: #f0f0f0;
}
.ms-option input {
margin-right: 8px;
}
.ms-option.ms-all {
border-bottom: 1px solid #eee;
font-weight: bold;
}
</style>
</head>
<body>
<div class="ms-wrapper" id="msWrapper">
<div class="ms-box" id="msBox">
<span id="msLabel">Seçiniz</span>
<span class="ms-arrow">▼</span>
</div>
<div class="ms-dropdown" id="msDropdown">
<label class="ms-option ms-all">
<input type="checkbox" id="msAll"> Tümü
</label>
<!-- Seçenekler buraya jQuery ile veya doğrudan eklenebilir -->
<label class="ms-option"><input type="checkbox" class="ms-item" value="1"> Seçenek 1</label>
<label class="ms-option"><input type="checkbox" class="ms-item" value="2"> Seçenek 2</label>
<label...