Code
  • 首页
  • cpu-architecture
  • performance
  • c++
  • branch-prediction
  • java
2024-02-17 06:00:02

jQuery添加属性

htmljquerytags

我如何添加一个属性到特定的HTML标签在jQuery?

例如,像这个简单的HTML:

<input id="someid" />

然后添加一个属性disabled="true",如下所示:

<input id="someid" disabled="true" />

当前回答

使用以下代码:

<script> 
   $('#someid').attr('disabled', 'true'); 
</script>
2018-10-20 11:47:29

其他回答

$('#someid').attr('disabled', 'true');
2011-05-13 17:31:49
$('#someid').attr('disabled', 'true');
2011-05-13 17:32:00
$('.some_selector').attr('disabled', true);
2011-05-13 17:32:14

使用以下代码:

<script> 
   $('#someid').attr('disabled', 'true'); 
</script>
2018-10-20 11:47:29
$('#yourid').prop('disabled', true);
2016-03-28 06:29:20

推荐文章

  • 使伸缩项目正确浮动
  • 可以在setInterval()内部调用clearInterval()吗?
  • 无法读取未定义的属性“msie”- jQuery工具
  • 形式内联内的形式水平在twitter bootstrap?
  • 自定义元素在HTML5中有效吗?
  • 如何触发自动填充在谷歌Chrome?
  • jQuery:执行同步AJAX请求
  • 创建圈div比使用图像更容易的方法?
  • jQuery表格排序
  • 如何禁用文本选择使用jQuery?
  • 为什么Chrome浏览器不正确地确定页面是在不同的语言,并提供翻译?
  • 如何停止事件冒泡复选框点击
  • 在网页上用鼠标模拟震颤(例如帕金森病)?
  • Bootstrap抛出Uncaught错误:Bootstrap的JavaScript需要jQuery
  • 如何改变文本区域的边框颜色:焦点

aliyun

最新文章

  • 如何删除默认的导航栏空间在SwiftUI导航视图
  • 我可以列出所有的标准Go包吗?
  • 证书验证失败:无法获得本地颁发者证书
  • 警告:API ' variable . getjavacompile()'已过时,已被' variable . getjavacompileprovider()'取代
  • 打开同一目录两次
  • 实体框架核心:在上一个操作完成之前,在此上下文中开始的第二个操作
  • NullInjectorError: AngularFirestore没有提供程序
  • 如何为构造函数定制Visual Studio的私有字段生成快捷方式?
  • 从元组/数组值派生联合类型
  • 如何在Angular2中截断文本?
  • 安装tzdata非交互式
  • ionic 2 - Error在Android Studio中找不到Gradle的安装版本
  • 如何查看所有地区所有正在运行的Amazon EC2实例?
  • 当使用pip3安装包时,“Python中的ssl模块不可用”
  • 安装APK时出现错误

标签

cpu-architectureperformancec++branch-predictionjavaundogit-commitgitversion-controlgit-remotegit-pushgit-branchgit-pullgit-fetchpythongeneratoriteratorjsonmime-typescontent-typearraysjavascriptgit-addcode-formattingcstandards-complianceoperatorscommentsdynamic-memory-allocationstackmemory-managementheap-memorylanguage-agnosticoverwritebackground-colorbrowserhtmldomjqueryvisibilityuse-strictsyntaxjslintremote-branchgit-checkoutpython-moduleidiomsprogram-entry-pointnamespacesbranch
2025 code 京ICP备15047053号-1