本文介绍了如何同时对某些div产生作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我有一些div元素,它们的ID是1,2,3,...
这些div具有内部div,根据其外部div,其dispaly属性为none,其id为1_d,2_d,3_d....例如,id为1的div的内部div为1_d.
我想在应用mouseenter事件时显示内部div.
当我喜欢下面的代码时,就可以了:

Hi.
I have some div element that their ids are 1,2,3,...
These div s have internal div s which their dispaly property are none and their ids are 1_d,2_d,3_d,... according to thir external div,for example internal div for div with id:1 is 1_d.
I want to show internal divs when mouseenter event is applied.
when I do like below codes,it is ok:

$("#" + 1).mouseenter(function () {
        $("#" + 1 + '_d').stop(true, true).show('clip');
    }).mouseleave(function () {
        $('#' + 1 + '_d').stop(true, true).hide('clip');
    });
    $("#" + 2).mouseenter(function () {
        $("#" + 2 + '_d').stop(true, true).show('clip');
    }).mouseleave(function () {
        $('#' + 2 + '_d').stop(true, true).hide('clip');
    });



但是当我想使用"for"时,它会出现问题:



but when i want to use "for" it has problem:

for (var i = 1; i < 3; i++) {
            var item_d = count + '_d';
            $("#" + i).mouseenter(function () {
                $("#" + item_d).stop(true, true).show('clip');
            }).mouseleave(function () {
                $('#' + item_d).stop(true, true).hide('clip');
            });
        }



为了使用"for"而不是单独编写它们,该怎么办?
另一个问题是在Fire Fox中,当我将鼠标悬停在div上时,此效果会重复执行直到鼠标离开div,这个问题只是Fire Fox,我该怎么做才能防止重复执行此效果?
请帮帮我.
预先感谢.



what can I do in order to use "for" instead of writing them separately?
Another question is that in Fire Fox,when my mouse over a div ,this effect execute repeatedly until mouse leave the div,this problem is just is Fire Fox,what can i do to prevent executing this effect repeatedly?
Please help me.
Thanks in advance.

推荐答案




这篇关于如何同时对某些div产生作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 08:56