On my website I make a request to the server PHP
with AJAX
, and I bring some links already created in PHP
. All right up to here, but the problem is that I want to change these links to href
with JavaScipt
, but I do not change the URL of the links, this is my code:
var theLinks = document.querySelectorAll(".paginacion a");
theLinks.forEach(function(element, index) {
element.href = "http://es.stackoverflow.com";
});
This problem only happens to the links brought by AJAX (they have the "pagination" class), since if I try to change the href
of the links that are aesthetically on the page, those that were NOT brought by AJAX
, if you change the href
. For example, if I execute the following code instead of the previous one, I change the url of all the links, except those that have the class paginacion
.
var theLinks = document.querySelectorAll("a");
theLinks.forEach(function(element, index) {
element.href = "http://es.stackoverflow.com";
});
I hope and you can help me, I have several days giving back to the code and I can not find a solution, thanks.