How to get the data from json in jquery -
When I click on the event, I want to get value from Jason Set and that value is stored in a variable and The function is passed
html
& lt; Ul class = "list-group" & gt; & Lt; Li class = "list-group-object" id = "driver 1" & gt; Driver 1 & lt; / Li & gt; & Lt; Li class = "list-group-item id =" driver2 "" & gt; Driver 2 & lt; / Li & gt; & Lt; Li class = "list-group-object" id = "driver 3" & gt; Driver 3 & lt; / Li & gt; & Lt; Li class = "list-group-item" id = "driver 4" & gt; Driver 4 & lt; / Li & gt; & Lt; Li class = "list-group-item" id = "driver5" & gt; Driver 5 & lt; / Li & gt; & Lt; / Ul & gt; Jquery
var driverLocation = {"Driver1": "12.98180953,77.44056702", "Driver 2": "12.89079587,77.35954285", "Driver 3 ":" 12.81046221,77.44056702 "," Driver 4 ":" 12.85197115,77.74406433 "," Driver 5 ":" 13.17710836,77.8401947 "} $ (document) .ready (function () {$ (" list-group-item "." ("Click", function () {warning ("hi"); var selection = $ (this) .attr ('id'); var location = driver location [selection]; location manager (e. Location , Map)}); }); This returns unwanted references error: $ is not defined
Two have a jquery script tag in your head? If not, you will need to add one, because jQuery has not been packaged with browsers.
& lt; Head & gt; & Lt; Script src = "jquery-1.10.2.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt;
Comments
Post a Comment