: not example

by Kheema Pandey

HTML

<div class="wrapper">
    
  <input type="text">

  <div class="hints-menu">
    <span class="hints-title"><span>Title 1</span></span>
    <span class="hint" title="Some title">Item 1</span>
    <span class="hint" title="Some title">Item 2</span>
    <span class="hint" title="Some title">Item 3</span>
    <span class="hints-title"><span>Title 2</span></span>
    <span class="hint" title="Some title">Item 4</span>
    <span class="hint" title="Some title">Item 5</span>
    <span class="hints-title"><span>Title 3</span></span>
    <span class="hint" title="Some title">Item 6</span>
    <span class="hint" title="Some title">Item 7</span>
    <span class="hint" title="Some title">Item 8</span>
    <span class="hint" title="Some title">Item 9</span>
  </div>

</div>

CSS

input:focus {
    outline: none;
}
input:focus + .hints-menu, 
input:not(:focus) + .hints-menu:hover {
    display: block;
}
.wrapper {
    width: 260px;
    margin: 30px auto;
}
input {
    width: 252px;
    height: 28px;
    padding: 0 4px;
    line-height: 20px;
    border: 1px solid #ddd;
    
    border-radius: 4px;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
}


.hints-menu {
    background: #fff;
    position: relative;
    display: none;
    width: 240px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ddd;

    border-radius: 4px;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
}
.hints-menu:before,
.hints-menu:after {
 	 bottom: 100%;
	 left: 83%;
	 border: solid transparent;
	 content: "";
	 height: 0;
	 width: 0;
	 position: absolute;
	 pointer-events: none;
}
.hints-menu:before {
	 border-color: transparent;
	 border-bottom-color: #ddd;
	 border-width: 9px;
	 margin-left: -9px;
}
.hints-menu:after {
	 border-color: transparent;
	 border-bottom-color: #fff;
	 border-width: 8px;
	 margin-left: -8px;
}
.hints-title,
.hint {
    display: block;
    width: 100%;
    height: 22px;
    line-height: 22px;
    color: #555;
}
.hints-title {
    position: relative;
    margin: 0 0 15px;
    text-align: center;
    font-size: 15px;
    border-bottom: 1px solid #555;
}
.hints-title span {
    background: #fff;
    position: absolute;
    top: 50%;
    right: 10%;
    padding: 0 5px;
}
.hint {
    font-size: 14px;
    cursor: pointer;
}
.hint:hover {
    color: #6fa024;
}

JavaScript

$(function() {
    $(".hint").click(function(evt) {
        alert($(this).text());  
    });
});