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 "请添加项目!";
        }

 

转载于:https://www.cnblogs.com/jacketlin/p/5711337.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值