[英]JQuery .click function based on button id contains partial text
In my web app, a text tag, updateTender
is embedded in each of several buttons, all with a different prefix & suffix for later use. 在我的Web应用程序中,文本标签
updateTender
嵌入在多个按钮的每个按钮中,每个按钮都有不同的前缀和后缀供以后使用。 What is the Jquery code to begin the function upon button click, matched on id contains some text? 单击按钮后开始该功能的Jquery代码是什么,id上匹配的包含一些文本?
I unsuccessfully tried: 我尝试失败:
$("[id*='updateTender']").click(function(){
alert("clicked!");
});
but get no alert response/button is unresponsive. 但没有收到警报响应/按钮没有响应。
example button html: 示例按钮html:
<button id='1._updateTender__.14'>Update</button>
The code is working fine. 该代码工作正常。 Make sure you have added jQuery library in your project.
确保已在项目中添加了jQuery库 。
$("[id*='updateTender']").click(function(){ alert("clicked!"); });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <button id='1._updateTender__.14'>Update</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.