Note that there are some explanatory texts on larger screens.

plurals
  1. POMy div show/ hide code works fine on a static HTML page but doesn't work on a Wordpress 3.5.1 page
    primarykey
    data
    text
    <p>This is sort of a condensed version of the code, the real version is too long to post but this is enough to represent the concept. I am using this to switch guitar diagrams based on several choices represented by anchors with the corresponding id in the href="". After spending several days getting it to work just right on a static html page, the script won't work in a Wordpress page which is where I intend to use it. I have tried it with the script in the head or inline (which shouldn't matter) - but either way it will not function. I know that Wordpress and certain plugins use Jquery so there may be a version mismatch causing conflicts. I am not (yet) an expert in javascript but I know there are several ways to skin a cat as the saying goes, I just need to find one that plays nice with Wordpress. Any help would be greatly appreciated... </p> <pre><code>&lt;script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var divswitch = $('div.diagram_container a'); divswitch.bind('click',function(event){ var $anchor = $(this); var ids = divswitch.each(function(){ $($(this).attr('href')).hide(); }); $($anchor.attr('href')).show(); event.preventDefault(); }); }); &lt;/script&gt; &lt;style&gt; .diagram { margin: 0; width: 100%; } .diagram_container { width: 100%; } &lt;/style&gt; &lt;div id="RH_RW_Div" class="diagram_container" style="float:left; display:block;"&gt; &lt;div class="diagram_menu"&gt; &lt;a class="checked" href="#RH_RW_Div"&gt;&lt;span class="checkbox_label"&gt;Right Handed&lt;/span&gt;&lt;/a&gt; &lt;a class="unchecked" href="#LH_RW_Div"&gt;&lt;span class="checkbox_label"&gt;Left Handed&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;img class="diagram" src='images/RH_RW.gif' /&gt;&lt;br /&gt; &lt;/div&gt; &lt;div id="LH_RW_Div" class="diagram_container" style="float:left; display:none;"&gt; &lt;div class="diagram_menu"&gt; &lt;a class="unchecked" href="#RH_RW_Div"&gt;&lt;span class="checkbox_label"&gt;Right Handed&lt;/span&gt;&lt;/a&gt; &lt;a class="checked" href="#LH_RW_Div"&gt;&lt;span class="checkbox_label"&gt;Left Handed&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;img class="diagram" src='images/LH_RW.gif' /&gt;&lt;br /&gt; &lt;/div&gt; </code></pre>
    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.
 

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