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
Solution 1:
document.getElementById(id)
is Dom element. and it has no function hide
You have to use $('#'+id).hide
. Or $(document.getElementById(id)).hide
Solution 2:
$("#" + id).hide(...);
Don't use getElementById
if you have jQuery.
Also, to fix your initial code, here's how it should have looked like:
$(document.getElementById(id)).hide(...);
This is because jQuery doesn't extend DOM elements, but it can "convert" them into jQuery elements (which have those cute functions) with $()
.
Solution 3:
When using document.getElementById(..)
you cannot use jQuery functions like hide(..)
. Use the jQuery shorthand - $("#" + id)
Post a Comment for "Getbyelementid Hide?"