getByElementId hide?


document.getElementById(id).hide("slide", { direction: "down" }, 1000);

This is in my javascript file.

I'm trying to hide a div, which has the id of var 'id'.

The error console is listing that it isn't a function.


I don't think I'm getting the right element this way (using $("#" + id)).

Let's say im making the div like this: <div id="2">, and the javascript function is getting 2


document.getElementById(id) is Dom element. and it has no function hide

You have to use $('#'+id).hide. Or $(document.getElementById(id)).hide


$("#" + id).hide(...);

Don't use getElementById if you have jQuery.

Also, to fix your initial code, here's how it should have looked like:


This is because jQuery doesn't extend DOM elements, but it can "convert" them into jQuery elements (which have those cute functions) with $().


When using document.getElementById(..) you cannot use jQuery functions like hide(..). Use the jQuery shorthand - $("#" + id)


  • Adding libraries to portable python
  • Way to represent unknown file size in FTP LIST?
  • Celery + Redis - .get() hangs indefinitely after running smoothly for ~70 hours
  • What is happening when this code calls FUSE like this?
  • converting text file into xml using php?
  • C: Incompatible pointer type initializing
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Android full screen on only one activity?
  • FileReader+canvas image loading problem
  • Insert into database using onclick function
  • Deselecting radio buttons while keeping the View Model in synch
  • Fetching methods from BroadcastReceiver to update UI
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Resize panoramic image to fixed size
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Symfony2: How to get request parameter
  • Upload files with Ajax and Jquery
  • Weird JavaScript statement, what does it mean?
  • jquery mobile loadPage not working
  • GridView Sorting works once only
  • How to pass list parameters for each object using Spring MVC?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • WPF Applying a trigger on binding failure
  • Proper way to use connect-multiparty with express.js?
  • using HTMLImports.whenReady not working in chrome
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to stop GridView from loading again when I press back button?
  • Linking SubReports Without LinkChild/LinkMaster
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Django query for large number of relationships
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?