我希望使用jquery在我的页面中的某些特定条件下一次加载所有数据

时间:2016-03-22 11:56:29

标签: c# jquery asp.net asp.net-mvc

我有这个jquery函数。当我点击任何特定字符时它工作正常并带来数据。如果我点击“A”然后它会带来所有以A.开头的地方。但是如果我写了一些条件,我想立即加载所有国家而不管任何字符点击。

jQuery(function ($) {
    alert(1);
    //  Listen for Click
    $(".serving-nav a").click(function (e) {

        //  Get the Character
        var theChar = $(this).data('alpha');

        //  Hide Others
        $(this).parent().find('a').not($(this)).removeClass('active');
        $(".serving-data .serving-nav-data").stop(true, true).slideUp(500);

        //  Show the Related
        $(this).addClass('active');
        $(".serving-data .serving-nav-data[data-alpha='" + theChar + "']").stop(true, true).slideDown(500);

        //  Prevent Default
        e.preventDefault();
        return false;
    });

    //  Trigger Click on Active One
    $(".serving-nav a.active").click();
});

1 个答案:

答案 0 :(得分:1)

看起来你只是这样做:

$(".serving-data .serving-nav-data').show();

或者,如果你仍然想要它们动画:

$(".serving-data .serving-nav-data').stop(true, true).slideDown(500);

基本上,如果您不想根据data-alpha属性进行选择,请不要包含该选择器。