Javascript jquery选择器从with表访问定位点

Javascript jquery选择器从with表访问定位点,javascript,jquery,css,Javascript,Jquery,Css,我想访问我的jquery中的anchor标记,如下所示。我想在jquery中选择每个锚点并向其添加一个单击事件 <table id="table1"> <tr> <th>Tags</th> <th>ID</th> <th>Batch ID</th> <th>Source</th> <th>Date</th>

我想访问我的
jquery
中的
anchor
标记,如下所示。我想在
jquery
中选择每个锚点并向其添加一个单击事件

<table id="table1">
<tr>
    <th>Tags</th>
    <th>ID</th>
    <th>Batch ID</th>
    <th>Source</th>
    <th>Date</th>
    <th>Details
        <div id="detailsdiv">
         <a href="#" id="default">Default</a>&nbsp;|&nbsp;
         <a href="#" id="wrap">Wrap</a>
        </div>
    </th>
    <th>Account Name</th>
    <th>Col15</th>
    <th>Col16</th>
    <th>Col17</th>
    <th>Col18</th>
  </tr>

标签
身份证件
批次ID
来源
日期
细节
| 
帐户名
可乐15
Col16
Col17
Col18

使用以下选项选择锚定标记:

$("table #detailsdiv a")
并使用以下方法应用单击功能:

$("table #detailsdiv a").on("click", function() {
    //use this to select the element that has been clicked
    $(this);        

    //Do click functionality here
});
或者,您也可以直接使用jQuery方法:

 $("table #detailsdiv a").click(function() {
     //use this to select the element that has been clicked
     $(this);         

     //Do click functionality here
 });

使用以下选项选择定位标记:

$("table #detailsdiv a")
并使用以下方法应用单击功能:

$("table #detailsdiv a").on("click", function() {
    //use this to select the element that has been clicked
    $(this);        

    //Do click functionality here
});
或者,您也可以直接使用jQuery方法:

 $("table #detailsdiv a").click(function() {
     //use this to select the element that has been clicked
     $(this);         

     //Do click functionality here
 });
试试这个:

$('#detailsdiv a').click(function(event){

    // Cancel the default action (navigation) of the click.
    event.preventDefault();

    // You can get the id of clicked link
    alert(this.id);

    // Your code goes here..
});
试试这个:

$('#detailsdiv a').click(function(event){

    // Cancel the default action (navigation) of the click.
    event.preventDefault();

    // You can get the id of clicked link
    alert(this.id);

    // Your code goes here..
});
试一试

试一试

你也可以试试这个:

$('table  #detailsdiv a').click(function(e){
    alert(this.id);
});
你也可以试试这个:

$('table  #detailsdiv a').click(function(e){
    alert(this.id);
});

我有两个anhor我想访问这两个选择器将把你的单击功能应用于两个锚定标记。我有两个anhor我想访问这两个选择器将把你的单击功能应用于两个锚定标记。