Search code examples
jqueryselectorconflicting-libraries

What could possibly cause JQuery's selector to break?


I am trying to get an element using JQuery's selector, but it does not find it even though the element actually exists. Moreover, I can actually find the element using getElementById.

For example:

$('#outputDiv') gives me a null value. But document.getElementById("outputDiv") returns me the Div I was trying to access.

Any idea?


Solution

  • Are you using any other libraries that might overload $ ? I know that e.g. that Prototype does this.

    You might want to try issuing a jQuery('#outputDiv') instead to see if it is actually jQuery that you are invoking.