• 设置密码可见与不可见


    1、prop()方法应该用于解锁属性值,例如DOM属性(如selectedIndex,tagName,nodeName,nodeType,ownerDocument, defaultChecked, 和 defaultSelected)。

    提示:如需检索 HTML 属性,请使用 attr() 方法代替。

    提示:如需移除属性,请使用 removeProp()方法。

    2、返回属性的值:

      $(selector).prop(property);

    3、设置属性和值:

      $(selector).prop(property,value);

    4、使用函数设置属性和值:

      $(selector).prop(property,function(index,currentvalue));

    5、设置多个属性和值:

      $(selector).prop({property:valueproperty:value,...})

    例子:<p><b>注意:</b>确认或取消选中该复选框,然后单击按钮刷新内容。</p>
    <button>查看attr() 和 prop() 的值</button>
    <br><br>
    <input id="check1" type="checkbox" checked="checked">
    <label for="check1">Check me</label>
    <p id="p1"></p>

    $(document).ready(function(){
    $("button").click(function(){
    $("#p1").html("attr('checked'): " + $("input").attr('checked')
    + "<br>prop('checked'): " + $("input").prop('checked'));
    });
    });

    注意:确认或取消选中该复选框,然后单击按钮刷新内容。

     

     

    结果——attr('checked'): checked
    prop('checked'): true

     
     
  • 相关阅读:
    ZJOI2019 Day1 游记
    Codeforces Round #545 (Div. 1)
    AtCoder WTF 2019 C2. Triangular Lamps Hard
    析合树
    Codeforces Round #539 (Div. 1)
    Codeforces 1103 E. Radix sum
    Codeforces 1097 G. Vladislav and a Great Legend
    sts创建spring项目
    servlet项目demo
    IDEA中创建maven web项目
  • 原文地址:https://www.cnblogs.com/yuner-angel/p/7773147.html
Copyright © 2020-2023  润新知