jquery基于查询结果隐藏div [英] jquery hiding divs based on query results

查看:64
本文介绍了jquery基于查询结果隐藏div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中运行查询以查看呼叫者是否启用转发。结果页面是一种表格,用户可以使用它来更改他的呼叫转接,如果他选择的话。查询的结果可以是或不是,如果是,则转发给号码。我使用jquery来隐藏cfaDesc div,如果他选择了disabled单选按钮,那很好。

I have a page in which a query is run to see if a caller has forwarding enabled. The result page is a form that the user can use to make changes to his call forwarding if he chooses. the results from the query are either yes or no, and if yes, the forwarded to number. I am using jquery to hide the cfaDesc div if he selects the "disabled" radio button, that works great.

 $(document).ready(function() {

$("div.cfaDesc").hide();
$("input[name$='cfa']").click(function() {
    var test = $(this).val();
    $("div.cfaDesc").hide();
    $("#" + test).slideDown('slow');
});
});

我的问题是初始查询。如果他启用了它,我需要显示cfaDesc div。用上面的查询,不管结果如何,它都会被隐藏起来。我不确定如何根据在此代码之前运行的查询来更改hide / show属性。

my problem is the initial query. If he has it enabled, I need to show the cfaDesc div. with the above query, no matter what the result is, it will be hidden. I am not sure how to change the hide/show attribute based on the query that is run before this code.

推荐答案

您可以只需触发点击即可。

You can just trigger the click.

$(document).ready(function() {
    $("input[name$='cfa']").click(function() {
        var test = $(this).val();
        $("div.cfaDesc").hide();
        $("#" + test).slideDown('slow');
    }).click(); // this line trigger the click event
});

我不确定它是否正是您需要的,您的问题对我来说并不明确。如果已经在cfa输入中定义了该解决方案,该解决方案将滑动一些面板。

I'm not sure if it is exactly what you need, your question was not clear to me. This solution will slideDown some panel if it is already defined in your "cfa" input.

这篇关于jquery基于查询结果隐藏div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆