Skip to content

Instantly share code, notes, and snippets.

@marti1125
Last active October 11, 2015 18:18
Show Gist options
  • Save marti1125/3900310 to your computer and use it in GitHub Desktop.
Save marti1125/3900310 to your computer and use it in GitHub Desktop.
json igualdad corregido
<html>
<head>
<title>demo</title>
<meta charset="utf-8"/>
</head>
<body>
<div id="data">
</div>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var a = 0;
var b = 0;
$.getJSON('videos.json', function(data) {
$.each(data, function(key, val) {
$.each(val, function(key2, val2) {
a++;
var titulo = $('<span id=tit' + a + ' class=titulo>' + val2.titulo +'</span><br/>');
var descripcion = $('<span>' + val2.descripcion +'</span><br/>');
var latitud = $('<span>' + val2.latitud +'</span><br/>');
var longitud = $('<span>' + val2.longitud +'</span><br/>');
var camara = $('<span id=titcamara' + a + ' class="camara">' + val2.camara +'</span><br/><br/>');
$("#data").append(titulo);
$("#data").append(descripcion);
$("#data").append(latitud);
$("#data").append(longitud);
$("#data").append(camara);
});
});
});
$(".titulo").live("click",function () {
var titulo_id = $(this).attr('id');
var titulo_itemPosition = 0;
while (titulo_id!="tit"+titulo_itemPosition) {
titulo_itemPosition++;
}
var algo = $('#titcamara' + titulo_itemPosition).html();
alert(algo);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment