I have a box with two dropdownlist . box content change when second dropdown change. box contain ul with lot of li , i want when clicked on li get li content . this do for first time when page load , but after box content change , my script not run.
this is my code (when dropdown change and box content change):
$.ajax({url: '/Symfony/web/app_dev.php/linknews?s='+target+'&&c='+select,
success: function(output) {
var list = document.getElementById(news_list);
var line = document.getElementById("line");
$(list).empty();
var newss = JSON.parse(output);
newss.forEach(function(entry){
var link = document.createElement("a");
var linkcontent = document.createTextNode(entry["title"]);
link.appendChild(linkcontent);
link.title = entry["title"];
link.href = entry["address"];
var div = document.createElement("div");
div.innerHTML += ' ';
div.setAttribute("class" , "news-bottom");
var li = document.createElement("li");
li.appendChild(link);
li.appendChild(div);
list.appendChild(li);
$(line).show();
});
}
});
and code that show to me li content:
$(document).ready(function($)
$("#news-list li a").click(function() {
var name = this.getAttribute('href');
alert(name);
}));
i don't know when box content change , why my script not run?!