zoukankan      html  css  js  c++  java
  • jquery设置元素的readonly和disabled


    Jquery的api中提供了对元素应用disabled和readonly属性的方法,在这里记录下。如下:
     1.readonly
        $('input').attr("readonly","readonly")//将input元素设置为readonly
        $('input').removeAttr("readonly");//去除input元素的readonly属性
      
        if($('input').attr("readonly")==true)//判断input元素是否已经设置了readonly属性

        对于为元素设置readonly属性和取消readonly属性的方法还有如下两种:
        $('input').attr("readonly",true)//将input元素设置为readonly
        $('input').attr("readonly",false)//去除input元素的readonly属性

        $('input').attr("readonly","readonly")//将input元素设置为readonly
        $('input').attr("readonly","")//去除input元素的readonly属性
     2.disabled
     

        $('input').attr("disabled","disabled")//将input元素设置为disabled
        $('input').removeAttr("disabled");//去除input元素的disabled属性
      
        if($('input').attr("disabled")==true)//判断input元素是否已经设置了disabled属性

      

      对于为元素设置disabled属性和取消disabled属性的方法还有如下两种:
        $('input').attr("disabled",true)//将input元素设置为disabled
        $('input').attr("disabled",false)//去除input元素的disabled属性

        $('input').attr("disabled","disabled")//将input元素设置为disabled
        $('input').attr("disabled","")//去除input元素的disabled属性

  • 相关阅读:
    搬家通知
    URL tailing slash
    HowTo: Linux Server Change OR Setup The Timezone
    [引] Security tips for web developers
    [转] Finding the Best Programmer's Font
    Recovering deleted Records
    How to stop uwsgi when no pidfile in config?
    [uwsgi] no request plugin is loaded, you will not be able to manage requests.
    Debian Environment Variables
    Memcached vs. MongoDB vs. Redis Comparison
  • 原文地址:https://www.cnblogs.com/gengaixue/p/2718639.html
Copyright © 2011-2022 走看看