Note that there are some explanatory texts on larger screens.

plurals
  1. PONew to Javascript. Attempting to make an onClick gallery for a personal site
    primarykey
    data
    text
    <p>So I'm new to Javascript and while I've looked around at as much as I could understand I don't really know what I'm doing or looking for at all.</p> <p>MY GOAL: I am making a gallery and for the items that have multiple views or images I want to give the corresponding thumbnails an onClick function that will change out the displayed img and p. </p> <p>EXAMPLE: An item in the gallery has 4 images I want to display. When the item is selected, the page loads with the first of the 4 images and some copy displayed along with 4 thumbnails. When any of the 4 thumbnails are selected, the image and copy will change.</p> <p>My syntax skill are lacking drastically (I'm literally just getting past "Hello World") but based on the very little that I know I would assume that I would be trying to do something like the following:</p> <p>HEAD --> script --> var img="imgID" var p="pID";</p> <p>function onload (default, "image1", "copy1");</p> <p>function onClick display (imgID, pID)</p> <p>&lt;-- script &lt;-- HEAD </p> <p>Body --> div --></p> <p>img id="get imgID" p id="get pID"</p> <p>&lt;-- div</p> <p>div --></p> <p>img id="thumb1" onClick imgID="image1" pID="copy1"; </p> <p>img id="thumb2" onClick imgID="image2" pID="copy2"; </p> <p>img id="thumb3" onClick imgID="image3" pID="copy3"; </p> <p>img id="thumb4" onClick imgID="image4" pID="copy4"; </p> <p>&lt;-- div &lt;-- Body</p> <p>As I mentioned, since I am new to this, I don't fully understand the limitations of functions, or display or default or how to properly pull var values so if anyone has any thoughts on if this is fairly simple or how to get this to work - or may be able to recommend any tutorials to start with that are more object based please let me know.</p> <p>Thank you in advance</p> <p>-CJ </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload