javascript - Wordpress hover over link and several elements change -
this wordpress home page has following html content section (the middle section 3 columns of divs)
<div class="seewidgets">[widgets_on_pages id="home page middle box"]</div> <div class="top-area"> <div class="image"> <img alt="primary care" src="/wp-content/uploads/scenarios/primary_care.png" /> </div> <div id="contact_box" class="home_side_box"> <div class="clients"> <img alt="contact us" src="/wp-content/uploads/buttons/contact_button.png" /> </div> </div> <div class="home_side_box home_side_box_gap"> <div class="home_side_box_heading">social media</div> //social media stuff </div> <div class="home_side_box home_side_box_gap"> <div class="home_side_box_heading">example clients</div> <div class="clients"> <img alt="" src="/wp-content/themes/twentytwelve/images/client.png" /> </div> </div> <div class="home_text_box" id="scenario_intro_text_div"> <p>if work in primary healthcare know can happen. </p><p>your staff may required handle difficult ... <a href='/primary-care'>read more</a></p> </div> </div> </div> </div>
as can see, there list of sectors on left, wordpress menu, central image, central text , on right, example client.
baring in mind website written in wordpress , content above entered in 'edit page' part of wordpress, not in template (although have complete access template files), can tell me way can have user hover on sector on left, , central image, central text , right hand side client image change match sector hovered over?
the main problem have list of sectors in wordpress menu , if possible, i'd stay way, can hard code if necessary.
you'll need use jquery.
this should started:
$('#menu-item-65').mouseover(function() { // when element moused over, change html elsewhere on page $('.top-area .image').html('<img src="path/to/your/image.jpg" />'); $('.home_side_box .clients').html('<img src="path/to/your/other/image.jpg" />'); $('#scenario_intro_text_div').html('<p>your text here</p>'); });
the first line means when #menu-item-65
(the id of 1 of individual li
s left "sectors" navigation menu) mouseovered, replaces inner html of elements targeted inside function whatever specify.
relevant links:
- http://api.jquery.com/html/
- http://api.jquery.com/mouseover/
- http://www.w3.org/tr/css2/selector.html
your theme has jquery loaded, need include in custom scripts file , make sure it's loaded (either putting script call in header.php
or adding via wp_enqueue_script
in functions.php
).
Comments
Post a Comment