You don't need to loop. The majority of jQuery methods will operate on each item in the matched set. Also, document
shouldn't be quoted. You want to select the actual document
object. If it's quoted, jQuery will be looking for an element with the tag name "document":
$(document).ready(function() {
$('.brandLinks li a').click(function () {
console.log('click');
});
});
Side note: It doesn't actually matter that the string "document" won't match anything in this case. The ready
method will operate on any jQuery object, regardless of what it contains (even if it's empty). It would make much more sense to others reading your code (and yourself in the future) to actually select the document
object though. For these reasons, I usually use the alternative form:
$(function () {
// This is the same as $(document).ready(function () {});
});
` tags in the javascript code? – Johan Oct 04 '12 at 07:43