Jquery 单击按钮时,调用警报

Jquery 单击按钮时,调用警报,jquery,Jquery,我有一个嵌套在表中的按钮,如下所示 <div class="marketoptionslist"> <table> <thead> <tr> <th>#</th> <th>Description</th> <th>Current</th> <th>Prev

我有一个嵌套在表中的按钮,如下所示

 <div class="marketoptionslist">
 <table>
 <thead>        
 <tr>          
 <th>#</th>          
 <th>Description</th>          
 <th>Current</th>          
 <th>Previous</th> 
 </tr></thead>      
 <tbody>    
 <tr class="marketoptionrow OP">      
 <td class="DisplayNumber">1</td>      
 <td class="DisplayName"> Flour</td>      
 <td><a class="button">click</a></td></tr> //when this button is clicked an alert must be displayed
 </tbody>
 </table>
 </div>

是否有其他方法可以检测按钮是否被单击?

简化脚本代码,如bellow remove else

<script>
$(function(){
$(".button").click(function (){
 alert("clickeddddd");
});
});
</scirpt>

$(函数(){
$(“.button”)。单击(函数(){
警报(“Clickedddd”);
});
});

只需在类中添加一个侦听器
。按钮
。够了

$(“.button”)。单击(函数(){
log(“单击类按钮”);
});

点击
点击

单击
可以使用事件冒泡

$(document).on("click" , ".button" , function()
{
   alert("Button clicked.");
});

这实际上是jQuery101,您应该能够自己研究这类简单的任务。我建议先使用
$(“.marketoptions列表a.button”)
而不是
$(“marketoptions列表a按钮”)
$(document).on("click" , ".button" , function()
{
   alert("Button clicked.");
});