I’m making Rails 3.1.1 app and trying to add some jQuery code to it.
jQuery didn’t seem do anything so I added border to all elements:
jQuery("*").css("border", "5px solid red");
When reloaded page, only html had that border. I can manipulate for example text color of all elements with jQuery via html-tag, but not spesific element id or class.
I know for sure that Javascript is functional and jQuery library is being loaded:
javascript:alert($);
brings:
function (selector, context) {
return new jQuery.fn.init(selector, context, rootjQuery);
}
Why can’t I access to elements?
wrap your init function inside
$(document).ready();like so: