Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="biz_geo_search">
	<input type="text" id="search_location_name_list" name="search_location_name_list" aria-label="Поиск" placeholder="Введите название региона" data-result-div-id="search_location_result" data-url-rule="" autocomplete="off">
<div id="search_location_result_list"></div>

<div class="row biz_geo_cities_list"><ul id="wt-list-locations"><li><a href="#">Алтайский край</a></li><li><a href="#">Амурская область</a></li><li><a href="#">Архангельская область</a></li><li><a href="#">Астраханская область</a></li><li><a href="#">Белгородская область</a></li><li><a href="#">Брянская область</a></li><li><a href="#">Владимирская область</a></li><li><a href="#">Волгоградская область</a></li><li><a href="#">Вологодская область</a></li><li><a href="#">Воронежская область</a></li><li><a href="#">Еврейская автономная область</a></li><li><a href="#">Забайкальский край</a></li><li><a href="#">Ивановская область</a></li><li><a href="#">Иркутская область</a></li><li><a href="#">Калининградская область</a></li><li><a href="#">Калужская область</a></li><li><a href="#">Камчатский край</a></li><li><a href="#">Кемеровская область</a></li><li><a href="#">Кировская область</a></li><li><a href="#">Костромская область</a></li><li><a href="#">Краснодарский край</a></li><li><a href="#">Красноярский край</a></li><li><a href="#">Курганская область</a></li><li><a href="#">Курская область</a></li><li><a href="#">Ленинградская область</a></li><li><a href="#">Липецкая область</a></li><li><a href="#">Магаданская область</a></li><li><a href="#">Москва</a></li><li><a href="#">Московская область</a></li><li><a href="#">Мурманская область</a></li><li><a href="#">Ненецкий автономный округ</a></li><li><a href="#">Нижегородская область</a></li><li><a href="#">Новгородская область</a></li><li><a href="#">Новосибирская область</a></li><li><a href="#">Омская область</a></li><li><a href="#">Оренбургская область</a></li><li><a href="#">Орловская область</a></li><li><a href="#">Пензенская область</a></li><li><a href="#">Пермский край</a></li><li><a href="#">Приморский край</a></li><li><a href="#">Псковская область</a></li><li><a href="#">Республика Адыгея</a></li><li><a href="#">Республика Алтай</a></li><li><a href="#">Республика Башкортостан</a></li><li><a href="#">Республика Бурятия</a></li><li><a href="#">Республика Дагестан</a></li><li><a href="#">Республика Ингушетия</a></li><li><a href="#">Республика Кабардино-Балкария</a></li><li><a href="#">Республика Калмыкия</a></li></ul></div>
              
            
!

CSS

              
                a {
  text-decoration: none;
  color: black;
  transition: 0.3s;}
a:hover {color: red;}

ul li {margin-bottom: 5px}

#search_location_result_list {padding: 15px 0;}

#search_location_result_list a {
  display: block;
  padding: 5px 15px;
}
#search_location_result_list a:hover {
	background: red;
  color: #fff;
}
              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', function () {
	// Вешаем обработчик на документ (или любой другой родительский элемент)
	document.body.addEventListener("input", function (event) {
		// Проверяем, является ли целевым элементом наш input
		if (event.target && event.target.id === "search_location_name_list") {
			const searchInput = event.target;
			const list = document.querySelector(".biz_geo_cities_list");
			const resultDiv = document.querySelector("#search_location_result_list");
			
			if (!searchInput || !list || !resultDiv) {
				console.error("Не удалось найти один или несколько элементов: input, список или результат.");
				return;
			}

			const searchTerm = searchInput.value.toLowerCase();

			// Элементы списка
			const listLi = list.querySelectorAll("li");

			// Переменная для хранения найденных элементов
			let resultHtml = "";

			// Перебираем элементы списка
			for (let i = 0; i < listLi.length; i++) {
				const item = listLi[i];
				const itemText = item.textContent.toLowerCase();

				// Если поисковый запрос найден в тексте элемента, добавляем его содержимое (ссылку) в результат
				if (itemText.indexOf(searchTerm) !== -1) {
					const linkElement = item.querySelector('a'); // Ищем элемент <a> внутри <li>
					if (linkElement) {
						resultHtml += linkElement.outerHTML; // Добавляем содержимое <a>
					}
				}

				// Проверяем вложенные списки
				const item_ul = item.querySelector('ul');
				if (item_ul) {
					for (let j = 0; j < item_ul.children.length; j++) {
						const subItem = item_ul.children[j];
						const subItemText = subItem.textContent.toLowerCase();
						const subLinkElement = subItem.querySelector('a'); // Ищем элемент <a> во вложенном <li>

						// Если поисковый запрос найден в тексте вложенного элемента, добавляем его содержимое (ссылку) в результат
						if (subItemText.indexOf(searchTerm) !== -1 && subLinkElement) {
							resultHtml += subLinkElement.outerHTML;
						}
					}
				}
			}

			// Выводим найденные элементы в блок результатов
			resultDiv.innerHTML = resultHtml;
      
      // если поле пустое
      if (searchInput.value== ''){ resultDiv.innerHTML = ''; }
      
		}
	});
});
              
            
!
999px

Console