1

我有一对 Jquery / Javascript 函数:

var id_testimonials = jQuery.noConflict();

//recusive function to power slider
function ttd_testimonial (elem) {

    elem.each (function () {
        if(id_testimonials(this).is(':visible')) {
            id_testimonials(this).hide(4000, function () {ttd_show (id_testimonials(this)); });

        }
    });
}

//figure out what to show
function ttd_show (elem) {
    container = elem.parent();

    if (elem.next().length !== 0) {
        next_elem = elem.next();
    } else {
        next_elem = container('.testimonial_single').first();
    }


    regen_elems = container('.testimonial_single');
    id_testimonials(next_elem).show(4000, function (){ ttd_testimonial(regen_elems); });
}

.hide()据我所知,火灾的完整功能正确无误。我也能够next_elem正确选择变量,所以我知道第二个函数正确接收它的参数。

但是,.show()永远不会触发(或似乎永远不会触发)。这似乎没有任何理由。

我试过了next_elem.show(args), 没有效果。next_elem.show()id_testimonials(next_elem).show()

此外,当我尝试添加.css()第二个函数时,dom 没有更新,但我可以alert()正确地对象属性。显然这两件事是相关的,但我无法找出原因。

JsFiddle 按要求

4

1 回答 1

1

您可以在控制台中看到此错误:

Uncaught TypeError: Property 'container' of object [object Object] is not a function

那是因为container它是一个 jQuery 对象,它不是一个函数。您必须使用 jQuery 遍历函数,例如find从某些上下文中获取元素。

代替

container('.testimonial_single')

container.find('.testimonial_single')
于 2013-09-12T09:44:53.143 回答