What I'm looking for is: concatenate several objects of the DOM in array dorma to make a call with a single variable that has the address of multiple children of the example tags: # menu > ul > li > a = > All this calls I seek to store it in a single variable.
Note: the code is not executed because a file called index1.php? variables is missing, I DO NOT KNOW HOW TO PLACE ANOTHER FILE
Another detail that I want to ask is this: You can print the code of a document.getElementId ('tag'); How to string?
addEventListener('load',evento,false);
// function evento() {
// var div
// div = document.getElementById('menu');
// var vec = div.getElementsByTagName('li');
// var a = vec[].getElementsByTagName('a').addEventListener('click'url,false);
// for(i=1; i <=a.length i++){
// console.log(a[i]);
// }
function evento() {
for (var i = 1; i <= 3; i++) {
document.getElementById('a'+i).addEventListener('click',url,false);;
}
}
function url(e) {
e.preventDefault();
var url = e.target.getAttribute('href');
cargarUrl(url);
}
var conex;
function cargarUrl(url) {
conex = new XMLHttpRequest();
conex.onreadystatechange = EstadoServido;
conex.open('GET',url,true);
conex.send();
}
function EstadoServido() {
var caja = document.getElementById('container')
if (conex.readyState == 4) {
caja.innerHTML = conex.responseText;
}else{
caja.innerHTML = 'Cargando .....'
}
}
<!DOCTYPE html>
<html>
<head>
<title>Comentarios</title>
<script src="ajax.js"></script>
</head>
<body>
<div id="menu">
<li><a href="#">Enlaces creados 1</a></li>
<li><a href="pagina1.php?fecha=12-10-2018">Enlaces creados 2</a></li>
<li><a href="pagina1.php?fecha=13-10-2018">Enlaces creados 3</a></li>
</div>
<div id="container" style="border : 1px solid red;padding: 60px;width: 300px; margin: 20px;"></div>
</body>
</html>