简体   繁体   中英

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. What is the Jquery code to begin the function upon button click, matched on id contains some text?

I unsuccessfully tried:

$("[id*='updateTender']").click(function(){
alert("clicked!");
});

but get no alert response/button is unresponsive.

example button html:

<button id='1._updateTender__.14'>Update</button>

The code is working fine. Make sure you have added jQuery library in your project.

 $("[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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM