...

View Full Version : hide(); is not a function



surreal5335
03-18-2009, 07:48 PM
I am trying to use a small piece of javascript to show and hide a jcarousel lite plugin.

After completely giving up on another piece of code I resorted back to code that works which is purely javascript.

The only thing is, the other script would show and hide content with css which I have read does not work with jcarousel. I am suppose to use the show () and hide () function instead.

The only problem is firebug says my my syntax is not a proper function.

the old code is this:


var currentUl = 1;
function showMe(n) {
document.getElementById("p_"+currentUl).style.display = "none";
document.getElementById("p_"+n).style.display = "block";
currentUl = n;

}



the new code is:



var currentUl = 1;
function showMe(n) {
document.getElementById("p_"+currentUl).hide();
document.getElementById("p_"+n).show();
currentUl = n;

}


This is how I understand to plug in the show and hide function, but firebug disagrees.

If you have any ideas as to how the hide and show should be set up please let me know.

Thanks a lot

Eldarrion
03-18-2009, 09:12 PM
Well, the problem really comes from the fact that show() and hide() are not JavaScript functions. jQuery does have them, but if you're not including jQuery in your document, you won't really be able to use them. Not sure if other frameworks have it as well. Other than that, you can define them if you want.

surreal5335
03-18-2009, 10:04 PM
Hi thanks for the response,

I made some changes to show the other elements that were hidden along with it.

Here is what I have now:



var currentUl = 1;
function showMe(n) {
$("p_"+currentUl).hide();
$("p_"+n).show(function ()
$("div#picture").show();

$("span#picture").show();
$("img#space").hide();
);
currentUl = n;

}



The error I am getting from firebug is: missing ' ) ' after $("div#picture").show(); argument

obviously that isnt the problem but I am not sure what is.

Any thoughts?

TinyScript
03-18-2009, 10:48 PM
ById("p_"+currentUl+"")
ById("p_"+n+"")

I think this will work
I don't know how to explain it, but it works this way sometimes.

other times this will work

ById('p_"+currentUl+"')
ById('p_"+n+"')

TinyScript
03-18-2009, 10:51 PM
I think it's because it wants a string for the ID so the whole thing has to be in quotes. Then you stick dynamic stuff in by putting it between "+ +". Sometimes, it works putting the variable between '+ +' . I have no clue which, but I try them all. LOL

surreal5335
03-18-2009, 11:59 PM
Thanks a lot for the help I have tried the suggestions and made a few more changes so now it shows and hides the elements in a proper order... The nice thing is no more errors... the problem is it still doesnt work


Here is new code I have



var currentUl = 1;
function showMe(n) {
$("img#space").hide();
$('"p_"+currentUl+').hide();
$("span#picture").show();
$("div#picture").show();
$('"p_"+n+').show();



currentUl = n;

};


I have no idea what to do, so hopefully you do.

Thanks a lot!

TinyScript
03-19-2009, 12:05 AM
Yeah, i don't get into Jquery stuff unless it's my own project. It's almost not worth using if you can make the effects yourself



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum