In This Javascript Tutorial we will See How To Get Display The Selected <li> Text Value From An <UL> List And Display The Value Into An Input Text On LI Item Click Event In JS And Netbeans Editor

Subscribe :

Project Source Code:

<!DOCTYPE html>
        <title>Javascript: get selected li from ul</title>
        <meta charset="windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <input type="text" id="txt">
        <ul id="list">
            var items = document.querySelectorAll("#list li");
            for(var i = 0; i < items.length; i++)
                items[i].onclick = function(){
                    document.getElementById("txt").value = this.innerHTML;


How To Get And Display Selected LI Text To Input Text In Javascript [with source code]
3.55 GEEK