var list = document.getElementsByTagName("li"); function markSelection() { if(list[0].style.fontWeight !== "bold") { list[0].style.fontWeight = "bold"; } else { list[0].style.fontWeight = "normal"; } } for (i = 0, len = list.length; i < len; i++){ list[i].onclick = markSelection; }