zoukankan      html  css  js  c++  java
  • jquery的几个常用方法

    • 第一部份关键词:

    .bind()

    .unbind()

    .css()

    .hasclass()

    .removeclass

    .parent()

    .children()

    .html()

    .hide()

    .show()

    .attr()

    .val()

    • 第二部份关键词:

    .find()

    • .unbind() .bind()的使用
    //给所有必填框添加框添加事件
            $('.bs').each(function (obj) {
                $(this).unbind().bind('blur', function () {
                    BSCheck(this);
                })
            })
    •  .css的使用
    $('.tbodyclose').each(function () {
                $(this).css("display", "none");
            });
    • .parent() .children()的使用
     //当先选择后面控件后,把金额设置成必填,把其它控件设置成非必填;把需要必填的字段设置为必填
            if ($(obj).attr("checked") == true) {
                $(obj).parent().children().each(function (obj) {
                    if ($(this).hasClass('input_money') == true) {
                        $(this).addClass("Required0");
                    }
                    if ($(this).hasClass('ds') == true) {
                        $(this).removeClass('Required');
                    }
                    if ($(this).hasClass('dsT') == true) {
                        $(this).removeClass('Required');
                    }
                    if ($(this).hasClass("fjbs") == true) {
                        $(this).addClass("Required");
                    }
                    if ($(this).hasClass("bs") == true) {
                        $(this).addClass("Required");
                    }
                })
            }
    • .html() .hide() .show() .attr() .val() 的使用
    //根据交通方法,显示每种交通方式可使用的等级
        function SetKZ(item) {
            var select1;
            JSMDXCBUS($(item).attr("id"));//当交通工具修改后,重算
            $(item).parent().children().each(function (allitem) {
                if ($(this).attr("name") == " - ") {
                    select1 = $(this);
                }
            });
            if ($(item).val() == "飞机") {
                $(select1).attr("class", "Required inputText");
                $(select1).show();
                $(select1).html('<option value="请选择">请选择</option><option value="头等舱">头等舱</option><option value="商务舱">商务舱</option><option value="经济舱">经济舱</option>');
            }
            else if ($(item).val() == "火车") {
                $(select1).attr("class", "Required inputText");
                $(select1).show();
                $(select1).html('<option value="请选择">请选择</option><option value="软卧">软卧</option><option value="硬卧">硬卧</option><option value="软座">软座</option><option value="硬座">硬座</option><option value="一等座">一等座</option><option value="二等座">二等座</option>');
            }
            else if ($(item).val() == "轮船") {
                $(select1).attr("class", "Required inputText");
                $(select1).show();
                $(select1).html('<option value="请选择">请选择</option><option value="一等舱">一等舱</option><option value="二等舱">二等舱</option><option value="三等舱">三等舱</option>');
            }
            else {
                $(select1).removeClass("Required");
                $(select1).hide();
                $(select1).val("");
                $(select1).html("");
            }
        }
    •  .find()
    var rownumber = $("#scgy_AddRowTable").find("tr").length;
            if (Number(rownumber) == 1) {
                return "请添加项目!";
            }
  • 相关阅读:
    访问localhost:8080 提示:位于 XDB 的服务器 localhost 要求用户名和密码 (引用)
    jdk在Windows下为什么要配置环境变量(引用)
    Eclipse 应用的初步认识
    linux awk命令
    CentOS7装好了开始装wrf了
    VMware 虚拟机安装 + Cent OS 7的下载与安装
    准备学习wrf
    全面学习ORACLE Scheduler特性(2)管理jobs
    全面学习ORACLE Scheduler特性(1)创建jobs
    Spring-MVC环境搭建
  • 原文地址:https://www.cnblogs.com/jacketlin/p/5711337.html
Copyright © 2011-2022 走看看