jQuery при наведении курсора мыши - PullRequest
0 голосов
/ 26 марта 2012

Когда вы нажимаете на кнопки, они загружают страницу, но при наведении у меня появляется следующий jQuery в шаблоне WordPress, который загружает мое содержимое в div:

jQuery(document).ready(
 function(){
 jQuery("#menu-item-72 a, #menu-item-71 a, #menu-item-70 a,
         #menu-item-69 a, #menu-item-68 a, #menu-item-67 a")
     .mouseover(function () {
       jQuery("#content").load(jQuery(this).attr("href") + " #content");
     });
});

Мне нужна помощь в настройке мышки

Так что, если я нахожусь на site.com/about и при наведении указателя мыши на меню содержимое загружается в div, то я бы хотел, чтобы указатель мыши вернулся к содержимому страницы about ... и так далее

Спасибо за любую помощь в этом

1 Ответ

0 голосов
/ 26 марта 2012

это грубое решение прямо здесь (возможно, потребуется оптимизировать):

jQuery(function() {
    (function($) {

        //original html storage
        var origHtml = [];

        //create the child selectors 
        var links = [
            '#menu-item-72 a',
            '#menu-item-71 a',
            '#menu-item-70 a',
            '#menu-item-69 a',
            '#menu-item-68 a',
            '#menu-item-67 a'
            ].join(',');

        //use jQuery to apply one handler for all links
        $('nearest_common_parent_to_links').on('mouseover', links, function() {

            var url = $(this).attr("href") + " #content";

            //remove the original content and store
            origHtml = $("#content").children().detach();

            //load your custom content                
            $("#content").load(url);

        }).on('mouseout', links, function() {

            //restore original html
            $("#content").html(origHtml);

        });
    }(jQuery));
});​
...