css/jquery 鼠标悬停在 jquery 轮播整圈后不起作用

发布于 2024-11-30 18:01:18 字数 3482 浏览 0 评论 0原文

我有一个圆形 jquery 轮播,它表示​​ 9 天的日历,其中 5 天可见。每一天都以垂直列表示。左右箭头控制 5 天的视图。轮播在所有浏览器中都能正常工作,但有一个例外。一旦你从第 9 列转到第 1 列(以圆形方式),样式就消失了,我的悬停效果也消失了。如果您继续沿相同方向前进,则列将丢失,直到您再次到达第 1 列。例如,如果您从第 9 列进入第 1 列并重复单击“下一个”按钮,则鼠标悬停样式将不再适用,直到您再次到达第 1 列。

长代码 - soz。

我从这里使用 msCarousel: http://www.marghoobsuleman.com/jquery-ms-carousel< /a>

JQUERY HTML

$('p.testSpotImage').wrap('<div class="imageWrapper" />');
$('.imageWrapper').append('<div class="imageBackground"></div>');

// Loop through all the div.thatSetsABackgroundWithAnIcon on your page
$('.imageWrapper').each(function () {
    var tdHeight = $(this).closest('td').height();
    $(this).height(tdHeight);
});
$('.imageWrapper').css("width", "187px");
$('.imageWrapper').css("position", "relative");
$('.imageWrapper').css("top", "0");
$('.imageWrapper').css("clear", "both");
$('.imageWrapper').css("overflow", "hidden");

$('.imageBackground').css({ 'opacity': '0' });
$('.imageBackground').css("background-color", "#a43802");
$('.imageBackground').css("height", "100%");
$('.imageBackground').css("width", "100%");
$('.imageBackground').css("position", "absolute");
$('.imageBackground').css("top", "0");
$('.imageBackground').css("z-index", "1");

$('p.testSpotImage span.dayContentTitle').css({ 'opacity': '0' });

$('.imageWrapper').hover(
function () {
    $(this).find('.imageBackground').stop().fadeTo(200, 1);
    $(this).find('p.testSpotImage span.dayContentTitle').stop().fadeTo(200, 1);
    $('p.testSpot a .dayContentDay', this).css("color", "#fff");
    $('p.testSpot a', this).css("color", "#fff");
},
function () {
    $(this).find('.imageBackground').stop().fadeTo(200, 0);
    $(this).find('p.testSpotImage span.dayContentTitle').stop().fadeTo(200, 0);
    $('p.testSpot a .dayContentDay', this).css("color", "#333");
    $('p.testSpot a', this).css("color", "#333");
});


$('.dayContent').hover(
    function () {
        $(this).stop().animate({ backgroundColor: "#a43802" }, 200);
        $('p.testSpot a .dayContentDay', this).css("color", "#fff");
        $('p.testSpot a', this).css("color", "#fff");
    },
    function () {
        $(this).stop().animate({ backgroundColor: '#ffffff' }, 200);
        $('p.testSpot a .dayContentDay', this).css("color", "#333");
        $('p.testSpot a', this).css("color", "#333");
});

来自一列的

<div class="contentColumnDay2">
    <table cellpadding="0" cellspacing="0" id="columnDay2">
        <tr>
            <td class="calendarHeader">
                <p><span class="dayHeader">Day 2</span><br />October 1, 2011</p>
            </td>
        </tr>
        <span id="ContentPlaceHolder1_labelDay2">
            <tr>
                <td class='dayContentImage' height='174' Width='187' BACKGROUND='/Images/day3_3pm.jpg'>
                    <p class='testSpotImage'>
                        <a href='CalendarMiniDetail.aspx?id=36' rel='shadowbox;height=220;width=330'>
                            <span class='dayContentImageDay'>10</span>AM<br><span class='dayContentTitle'>Fashion Show Debut</span>
                        </a>
                   </p>
               </td>
           </tr>
        </span>
    </table>
</div>

I have a circular jquery carousel that is a representation of a 9 day calendar with 5 days visible. Each day is represented in a vertical column. Arrows right and left control the view of the 5 days. The carousel works beuatifully in all browsers with one exception. Once you go from column 9 to column 1 (in circular fashion) the styling is gone and my hover effects are gone. If you continue the same direction the columns are missing until you get to column1 again. For instance, if you were clicking the next button repeatedly once you go from column/day9 and into column/day1 the mouseover stylings no longer work on the days until you reach column/day1 again.

Long code - soz.

I am using msCarousel from here: http://www.marghoobsuleman.com/jquery-ms-carousel

JQUERY

$('p.testSpotImage').wrap('<div class="imageWrapper" />');
$('.imageWrapper').append('<div class="imageBackground"></div>');

// Loop through all the div.thatSetsABackgroundWithAnIcon on your page
$('.imageWrapper').each(function () {
    var tdHeight = $(this).closest('td').height();
    $(this).height(tdHeight);
});
$('.imageWrapper').css("width", "187px");
$('.imageWrapper').css("position", "relative");
$('.imageWrapper').css("top", "0");
$('.imageWrapper').css("clear", "both");
$('.imageWrapper').css("overflow", "hidden");

$('.imageBackground').css({ 'opacity': '0' });
$('.imageBackground').css("background-color", "#a43802");
$('.imageBackground').css("height", "100%");
$('.imageBackground').css("width", "100%");
$('.imageBackground').css("position", "absolute");
$('.imageBackground').css("top", "0");
$('.imageBackground').css("z-index", "1");

$('p.testSpotImage span.dayContentTitle').css({ 'opacity': '0' });

$('.imageWrapper').hover(
function () {
    $(this).find('.imageBackground').stop().fadeTo(200, 1);
    $(this).find('p.testSpotImage span.dayContentTitle').stop().fadeTo(200, 1);
    $('p.testSpot a .dayContentDay', this).css("color", "#fff");
    $('p.testSpot a', this).css("color", "#fff");
},
function () {
    $(this).find('.imageBackground').stop().fadeTo(200, 0);
    $(this).find('p.testSpotImage span.dayContentTitle').stop().fadeTo(200, 0);
    $('p.testSpot a .dayContentDay', this).css("color", "#333");
    $('p.testSpot a', this).css("color", "#333");
});


$('.dayContent').hover(
    function () {
        $(this).stop().animate({ backgroundColor: "#a43802" }, 200);
        $('p.testSpot a .dayContentDay', this).css("color", "#fff");
        $('p.testSpot a', this).css("color", "#fff");
    },
    function () {
        $(this).stop().animate({ backgroundColor: '#ffffff' }, 200);
        $('p.testSpot a .dayContentDay', this).css("color", "#333");
        $('p.testSpot a', this).css("color", "#333");
});

HTML FROM ONE COLUMN

<div class="contentColumnDay2">
    <table cellpadding="0" cellspacing="0" id="columnDay2">
        <tr>
            <td class="calendarHeader">
                <p><span class="dayHeader">Day 2</span><br />October 1, 2011</p>
            </td>
        </tr>
        <span id="ContentPlaceHolder1_labelDay2">
            <tr>
                <td class='dayContentImage' height='174' Width='187' BACKGROUND='/Images/day3_3pm.jpg'>
                    <p class='testSpotImage'>
                        <a href='CalendarMiniDetail.aspx?id=36' rel='shadowbox;height=220;width=330'>
                            <span class='dayContentImageDay'>10</span>AM<br><span class='dayContentTitle'>Fashion Show Debut</span>
                        </a>
                   </p>
               </td>
           </tr>
        </span>
    </table>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囚你心 2024-12-07 18:01:18

当设置为循环模式时,jQuery Carousel 会出现错误。我认为世界上很大一部分人都在等待更新。

这就是我要做的。似乎旋转木马在第一个周期后正在重建,这将破坏您的悬停事件。相反,请尝试:

$('.dayContent').live({
    mouseenter:
       function()
       {

       },
    mouseleave:
       function()
       {

       }
   }

即使重建,这也会将事件保留在该类上。

jQuery Carousel is buggy when set to circular mode. I think a large portion of the world is waiting for the update.

Here's what I'd do. It seems like the carousel is being rebuild after the first cycle which is going to destroy your hover event. Instead try:

$('.dayContent').live({
    mouseenter:
       function()
       {

       },
    mouseleave:
       function()
       {

       }
   }

That will keep the event on that class even if rebuilt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文