设为首页 加入收藏

TOP

jquery的几个常用方法
2017-10-11 18:23:49 】 浏览:9960
Tags: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 "请添加项目!";
        }

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇js获取及判断键盘按键的方法 下一篇Windows系统镜像自动添加驱动程序

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目