Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JQuery doesn't seem to be working with hide() and show() :/

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

I'm trying to get some code working with JS. You can see it here:


The example code is (please note, the ID's change each time the page is loaded, as this will be used more as many as 25 listings per page, so I'm using random ID's)

Code:
<script type="text/javascript">
 function hXEGZQpOUu() {
 alert("HERE");
 $('rlRXubGlbF').show();
 $('hXEGZQpOUu').hide();
 }
</script>
 fdfsdf bla
sdf2 tablespoons tomato sauce
dfff bl
<div id="hXEGZQpOUu"><a href="javascript: hXEGZQpOUu();">...more </a></div>
<div id="rlRXubGlbF" style="display: none;">a  color
adding some more content
adding some more content
adding some more content
more stuff
adding some more content
asdfasdas
asdadasd
asdasdasd</div>


When you click the link, it shows the alert box with "HERE" in it, so I know the function is being called - yet it never seems to actually show the div :/

Any ideas? Been going around in circles for the last hour trying to get this working :(

TIA

Andy
 
Hi

Using the same "hXEGZQpOUu" for both [tt]function[/tt] name and element [tt]id[/tt] is a bad idea. The browsers will generate no explicit error message because this, but the actual behavior is hardly predictable and not consistent.

Feherke.
 
sfaik, the selector notation in jQuery is as follows (for ids)

Code:
$('[red]#[/red]rlRXubGlbF').show();
$('[red]#[/red]hXEGZQpOUu').hide();

however these might not give the effects you desire. you probably want the two events chained.

Code:
$('[red]#[/red]hXEGZQpOUu').hide('fast',$('[red]#[/red]rlRXubGlbF').show('slow'));

you might also want to stop the click from firing by returning false.
 
OMG I knew it had to be something simple - works a charm now - thanks :)

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top