I am create a drop down using ul li. I want to get value when I click on li. How can I get value for li ans set value in the drop down.
I am using this code.
<ul class="col-sm-8"> <li class="list-group-item" value="School">School</li> <li class="list-group-item" value="Collage">Collage</li> <li class="list-group-item" value="University">University</li> </ul>
Java scripts are now easily to unload from differentiate of the codes to using newly puzzles and games. Java has ever provided the websites on the resumewriterslist.com discounts are also in the nature of the java for its normal players.
You can get li value from your drop down list to use this code:
First you need to define a ID name in UL. For example:
<ul class="col-sm-8" id="MyULIDName"> <li class="list-group-item" data-value="School">School</li> <li class="list-group-item" data-value="Collage">Collage</li> <li class="list-group-item" data-value="University">University</li> </ul>
Follow this javascript code and apply it on your work.
<script type="text/javascript"> function getResultTarget(e) { e = e || window.event; return e.target || e.srcElement; } var ul = document.getElementById('MyULIDName'); ul.onclick = function(event) { var target = getResultTarget(event); var myvalue=target.innerHTML; alert(myvalue); }; </script>
Question and answer is powered by AnsPress.io