I have using JSON to retrieve data :
$(document).ready(function () {
var url = '<%: Url.Content("~/") %>' + "Products/GetMenuList";
$.getJSON(url, function (data) {
$.each(data, function (index, dataOption) {
$("#navmenu-v").append("<li><a href='javascript:DoNothing();' id='list'>"
+ dataOption.Name + "</a></li>");
});
$('#list').click(function () {
//add some content to div
});
});
});
I want to click on the #list, and then do any thing. But when I test with alert, it only works in the first list.
Can anyone tell me, how could I do that?
Thanks.
To select more than one elements by id you should use a better selector: