jquery - access specific data from fetched json file -


Hello I'm new to further development, I have brought Jason data and added it as html in the list & lt; Li & gt; item but my problem is that when I click on Jason on the list format, I need special information about that particular link which I clicked to log in to the console window.

  var data 1 = {" user ": [" deditum ":" 21:30 "," arrival ":" 23:30 "," duration ":" 1H 45m "," "Price": "2,400", "planeName": "auditor", "stop": "non-stop", "image": "indigo"}, {"depthtime": "21:30", "arrival "": "23:30", "Period": "1h 45m", "Price": "2,400", "Aviation": "Auditor", "Stop": "Non Stop", "Image": "Indiago "}]}; Var output = "& lt; ul & gt;"; (Data1.users in var i) {output = = "
  • + "& Lt; a href = '#' & gt; + "& Lt; Table & gt;" + "& Lt; tr & gt;" + "& Lt;" + "& lt; i & lt; / td>" + "& lt; td & gt;" + Data 1. Services [i] .depTime + "& lt; / td & gt; ; "+" & Lt; td & gt; "+ Data 1. Services [i]. + +" & Lt; / td & gt; + "& lt; td & gt;" + Data 1.Users [i] "+" & Lt; / td> "+" & lt; td & gt; "+" & lt; / td & gt; "+" & lt; TD & gt; "+ Data 1" + " & Lt; Tr & gt; "+" & Lt; Td> "+" & Lt; / Td> "+" & Lt; TD & gt; "[+] + Data 1.Users [i] .planeName +" & lt; / Td> "+" & lt; Td> "+" & lt; / Td> "+" & lt; TD & gt; "+" & lt; / Td> "+" & lt; Td & gt; "+ Data1.users [i] .stop +" & lt; / Td> "+" & Lt; / Tr & gt; "+" & Lt; / Table & gt; "+" & Lt; / A & gt; "+" & Lt; / Li> ";} output + =" & lt; / Ul> ". Document.getElementById (" placeholder ") innerHTML = output; var add =" & lt; H1> "$" ("# Placeholder A"). Click (function () {event.preventDefault (); var value = // I'm running into trouble / / I get that specific & lt; li & Gt; want the value of the element and the depTime value that I clicked on console.log (value);}); add + = "& lt; / H1> "; Document.getElementById (" Add "). InnerHTML = add;
  •   Lt;; DOCTYPE html> gt; & gt; & gt; Top & gt; Title & gt; & lt; / title & gt; & lt; / head & gt; Body & gt; & lt; Gt; & lt; div id = "placeholder" & gt; & lt; / div & gt; & lt; div id = "add" & gt; & lt; / div & gt; & lt; / body & gt; & Script; script type = "text / javascript" src = "jquery-1.11.1.min.js" & gt; & lt; / script & gt; script type = "text / javascript" src = "script .js "& gt; & lt; / script & gt; & gt;  

    < Div class = "post-text" itemprop = "text">

    you

  • / Code> Elements of the element can take the required value:

      $ ("# placeholder a"). Click (function (event) {event.preventDefault (); var index = $ (Event.currentTarget) .Parent (). Index (), value = data1.users [index]; console.log (value);});  


  • Comments

    Popular posts from this blog

    apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

    c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

    c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -