Good day.
I have ul list on my page.
me need get value ul
when i click on li
.
Html:
.ddlist {
position: absolute;
width: 316px;
display: none;
background-color: #fff;
border: 1px solid #ccc;
border-top: none;
margin: 0;
padding: 0;
margin-top: -3px;
}
.ddlist li {
list-style: none;
padding: 5px;
}
<ul id="list_t_railway" class="ddlist" style="display: block;">
<li>Белорусский вокзал</li>
<li>Казанский вокзал</li>
<li>Киевский вокзал</li>
</ul>
For get value ul i use script:
$("#list_t_railway").on("click", function(){
alert($(this).val());
});
But i get empty value...
Tell me please why i get empty value and how write right?
P.S.: all script for test you can see here
.val()
looks for thevalue
property of the element – Numeratorval()
function is only intended forinput/textarea/select
elements. what kind of value are you expecting from yourul
? – Yellowhammer