Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery mouseenter toggle
    primarykey
    data
    text
    <p>I have three 'tabs' which I am using images for as follows:-</p> <p><img src="https://i.stack.imgur.com/oCx1S.png" alt="enter image description here"></p> <p>For each tab there are three images:-</p> <ul> <li>bookaccount.png (default - orange)</li> <li>bookaccount-a.png (active - white)</li> <li>bookaccount-h.png (hover - blue)</li> </ul> <p>the same with bookcash.png and bookguest.png.</p> <p>By default I am wanting the 'Guest' to stay as the active tab and the other tabs in orange which is what I have:</p> <pre><code>&lt;div id="main-online-user"&gt; &lt;a href="javascript:void(0)" onclick="changesrc('main-online-frame','http://www.marandy.com/one2oneob/login-guest.php')"&gt;&lt;img alt="One 2 One Guest" id="img-onlinebooking-guest" class="left" src="images/bookguest-a.png" /&gt;&lt;/a&gt; &lt;a href="javascript:void(0)" onclick="changesrc('main-online-frame','http://www.marandy.com/one2oneob/login.php')"&gt;&lt;img alt="One 2 One Account" id="img-onlinebooking-acc" class="left" src="images/bookaccount.png" /&gt;&lt;/a&gt; &lt;a href="javascript:void(0)" onclick="changesrc('main-online-frame','http://www.marandy.com/one2oneob/login-guest.php')"&gt;&lt;img alt="One 2 One Cash" id="img-onlinebooking-cash" class="left" src="images/bookcash.png" /&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>For the hover events I am doing it like this at the moment:-</p> <pre><code> $("#img-onlinebooking-guest").hover(function() { $(this).attr("src", "images/bookguest-h.png"); }); $("#img-onlinebooking-guest").mouseleave(function() { $(this).attr("src", "images/bookguest.png"); }); </code></pre> <p>The problem is that (say Guest is active - white), and I hover over it, when I leave that element it will change the image back to orange (default) when it is still the active tab.</p> <p>What I want to be able to do is either:-</p> <p>If the image is an active element, when you hover over it, nothing happens. (this is probably the better option)</p> <p>or, if the active element is hovered, on mouseout it reverts back to the colour it was before the mouseenter event.</p> <p>I'm not sure how I can do this so I would appreciate any help!</p> <p>(I know I can use jQuery tabs, but the client is wanting these images so I don't have a choice)</p> <p><strong>EDIT::</strong></p> <p>I have added 'active' class to #img-onlinebooking-guest and have changed the jQuery to:-</p> <pre><code> $("#img-onlinebooking-guest").click(function() { $(this).addClass('active'); $('#img-onlinebooking-cash, #img-onlinebooking-acc').removeClass('active'); $(this).attr("src", "images/bookguest-a.png"); $('#img-onlinebooking-acc').attr("src", "images/bookaccount.png"); $('#img-onlinebooking-cash').attr("src", "images/bookcash.png"); }); $("#img-onlinebooking-acc").click(function() { $(this).addClass('active'); $('#img-onlinebooking-guest, #img-onlinebooking-cash').removeClass('active'); $(this).attr("src", "images/bookaccount-a.png"); $('#img-onlinebooking-guest').attr("src", "images/bookguest.png"); $('#img-onlinebooking-cash').attr("src", "images/bookcash.png"); }); $("#img-onlinebooking-cash").click(function() { $(this).addClass('active'); $('#img-onlinebooking-guest, #img-onlinebooking-acc').removeClass('active'); $(this).attr("src", "images/bookcash-a.png"); $('#img-onlinebooking-guest').attr("src", "images/bookguest.png"); $('#img-onlinebooking-acc').attr("src", "images/bookaccount.png"); }); $('#img-onlinebooking-guest:not(.active)').hover( function () { $(this).attr("src", "images/bookguest-h.png"); }, function () { $(this).attr("src", "images/bookguest.png"); }); $('#img-onlinebooking-acc:not(.active)').hover( function () { $(this).attr("src", "images/bookaccount-h.png"); }, function () { $(this).attr("src", "images/bookaccount.png"); }); $('#img-onlinebooking-cash:not(.active)').hover( function () { $(this).attr("src", "images/bookcash-h.png"); }, function () { $(this).attr("src", "images/bookcash.png"); }); </code></pre> <p>It seems quite messy but anyway, it is working for the 'Guest' tab where I have added the class 'active' within the HTML, but doesn't work properly for the other tabs. If I click 'Cash' it makes the images active (white) but on mouseout it is still changing the colour back to orange (default) when it should stay white as I have added the class 'active' to this element on click.</p> <p>Any ideas?</p> <p>You can see this here; <a href="http://www.marandy.com/one2onev2" rel="nofollow noreferrer">Link</a></p>
    singulars
    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