views:

30

answers:

2

I have a piece of html/javascript written in jQuery at http://pastebin.com/MzMPjtvF

My issue is the divs with images in them will only show up until $('.platform').hide() is ran, to the point that those divs won't even show up in $('.platform'). I'm not sure if its a bug or my lack of knowledge of jQuery

A: 

a have never used jquery, but isn't the id-selector a #, not .?

oezi
I don't think that's the problem here -- if you look at the code on pastebin.com you will see that there are multiple divs with the "platform" class. (I think) he's suggesting they aren't found even if he searches for them by id.
Andy E
+3  A: 

I'm assuming you mean that the windows.png and mac.png images disappear suddenly. This is because you are overwriting everything that is in the <div> with the id "download_button" using the following line (or the mac equivalent):

$("#download_button").html("Download Company5 for Windows");

Note that the html() method replaces all the html content of the element with the given content. In other words, this will also remove both of the images inside the #download_button, because they are part of it's html content.

Easiest way to avoid this, is, for example, to put the text itself you want to replace into a separate <span> with it's own ID and only overwrite the html() of that. That way you wont be removing the <div> tags within the parent element.

Rithiur
Doh. Brain not in gear. Thanks
aussiegeek