Note that there are some explanatory texts on larger screens.

plurals
  1. POusing jQuery to toggle hidden text that's in a wp_query loop
    primarykey
    data
    text
    <p>Ok so i have 5 images that when selected shows a load of information on the picture underneath it. The images and text are being stored in a custom contact type. Now I have it working with the last image which is the first post in the custom content type. I'me new to writing my own jQuery so not sure if it needs some kind of for each loop? </p> <p>Here the image class is given an ID so everyone is different </p> <pre><code>&lt;a href="#" class="tutorlink-&lt;?php the_id(); ?&gt;"&gt;&lt;img src="&lt;?php echo $TutorImageURL[0]; ?&gt;" alt="&lt;?php echo get_post_meta($att, '_wp_attachment_image_alt', true); ?&gt;" /&gt;&lt;/a&gt; &lt;?php endwhile; ?&gt; &lt;div class="tutor-block"&gt; &lt;img src="&lt;?php bloginfo('template_directory'); ?&gt;/images/click.png" alt="tutors"/&gt; &lt;/div&gt; &lt;div class="tutor-description"&gt; &lt;?php // The Loop while ( $tutors-&gt;have_posts() ) : $tutors-&gt;the_post(); ?&gt; </code></pre> <p>Here the containing div class is also given its own id </p> <pre><code>&lt;div class="tutor-description-inner-&lt;?php the_id(); ?&gt;"&gt; &lt;?php the_content(); ?&gt; &lt;/div&gt; </code></pre> <p>This script hides the text first.</p> <pre><code>&lt;script&gt; var id = &lt;?php echo $theID; ?&gt;; $('.tutor-description-inner-'+id+'').hide(); &lt;/script&gt; </code></pre> <p>Here is the script I have written so far which toggles the text for the last image.</p> <pre><code>&lt;script&gt; $(document).ready(function() { $('.tutorlink-'+id+'').click(function() { $('.tutor-description-inner-'+id+'').toggle('slow'); return false; }); }); &lt;/script&gt; </code></pre> <p>Ideas please? </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.
    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