javascript - Jquery-如何在这里使用 contains ?

标签 javascript jquery html contains

我如何使用 contains 来搜索占位符来搜索单词“name”并设置值,而不是搜索占位符的确切值。

这是 html:

      <input autocorrect="off" placeholder="full name here" id="order_billing_name" name="order[billing_name]" size="30" class="" type="text">

我如何使用 contains 来搜索“名称”并设置值,而不是搜索确切的值“此处的全名”

 $('[placeholder="full name here"]').val('name here');

最佳答案

您可以使用属性值包含选择器

$("[placeholder*=name]").val("name here")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<input autocorrect="off" 
       placeholder="full name here" 
       id="order_billing_name" 
       name="order[billing_name]" 
       size="30" 
       class="" 
       type="text">

关于javascript - Jquery-如何在这里使用 contains ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46537590/

相关文章:

javascript - 正则表达式也应该适用于 '-'

javascript - 消除隐藏输入字段的需要

html - 对齐分层复选框

html - 以相反的顺序显示 div

jquery - 居中表单动态添加元素保持居中?

javascript - 通过 Canvas 将 SVG 下载到 PNG 时如何避免出现黑色或空白图像?

javascript - body onload 和 window.onload 同时进行

javascript - 在没有绑定(bind)的情况下将值传递到从父组件到子组件的回调

javascript - Bootstrap 模态可点击 div

javascript - 将数据加载到使用 JSON 返回的表单字段时出现问题