javascript - jquery selector-accessing anchor from with table -


i want access anchor tag in jquery nested follows. want select each anchor , add click event in 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> 

select anchor tags using following:

$("table #detailsdiv a") 

and apply click functionality using .on() method:

$("table #detailsdiv a").on("click", function() {     //use select element has been clicked     $(this);              //do click functionality here }); 

alternatively, can use .click() jquery method directly:

 $("table #detailsdiv a").click(function() {      //use select element has been clicked      $(this);                //do click functionality here  }); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -