How to add click handlers to every element which has a certain class?
<p>I want to add on each element which has the class .ui-icon-trash a click handler which needs to provide a datatable object (this I have already) and the row which should be deleted. I do not know how to iterate over my elements to add the clickhandler and also I dont know how to retrieve the current tr for each iteration.</p>

<pre><code> $(".ui-icon-trash").click(function(){
        deleteRowFromTable(oTable, ????The TR of the current element????);          

    });
</code></pre>

<p>here is my table </p>

<pre><code>        &lt;table id="table_id" class="display"&gt;
        &lt;thead&gt;
            &lt;th&gt;Property&lt;/th&gt;
            &lt;th&gt;Value&lt;/th&gt;      
            &lt;th&gt;&lt;/th&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
            &lt;button id="create-property"&gt;Create new property&lt;/button&gt;

            &lt;tr &gt;
                &lt;td&gt;mailAddress_object&lt;/td&gt;
                &lt;td id="mailAddress_object" &gt;Message from SendALL 2.5&lt;/td&gt;      
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_1" name="mailAddress_object"&gt;&lt;/span&gt;&lt;/td&gt;                     
            &lt;/tr&gt;       

            &lt;tr &gt;
                &lt;td&gt;mjmj&lt;/td&gt;
                &lt;td id="mjmj" &gt;xcvxcv&lt;/td&gt;      
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_2" name="mjmj"&gt;&lt;/span&gt;&lt;/td&gt;                       
            &lt;/tr&gt;       

            &lt;tr &gt;
                &lt;td&gt;olol&lt;/td&gt;
                &lt;td id="olol" &gt;kjkkjk&lt;/td&gt;      
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_3" name="olol"&gt;&lt;/span&gt;&lt;/td&gt;                       
            &lt;/tr&gt;       

            &lt;tr &gt;
                &lt;td&gt;plsUrl&lt;/td&gt;
                &lt;td id="plsUrl" &gt;http://komm2.srs-management.de&lt;/td&gt;        
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_4" name="plsUrl"&gt;&lt;/span&gt;&lt;/td&gt;                     
            &lt;/tr&gt;       

            &lt;tr &gt;
                &lt;td&gt;scPwd&lt;/td&gt;
                &lt;td id="scPwd" &gt;sysadm&lt;/td&gt;     
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_5" name="scPwd"&gt;&lt;/span&gt;&lt;/td&gt;                      
            &lt;/tr&gt;       

            &lt;tr &gt;
                &lt;td&gt;smtp&lt;/td&gt;
                &lt;td id="smtp" &gt;YOUR_MAILSERVER&lt;/td&gt;     
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_6" name="smtp"&gt;&lt;/span&gt;&lt;/td&gt;                       
            &lt;/tr&gt;       

            &lt;tr &gt;
                &lt;td&gt;test&lt;/td&gt;
                &lt;td id="test" &gt;test3&lt;/td&gt;       
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_7" name="test"&gt;&lt;/span&gt;&lt;/td&gt;                       
            &lt;/tr&gt;       

            &lt;tr &gt;
                &lt;td&gt;useEncryption&lt;/td&gt;
                &lt;td id="useEncryption" &gt;false&lt;/td&gt;      
                &lt;td&gt;&lt;span class="ui-icon ui-icon-trash" id="deleteRow_8" name="useEncryption"&gt;&lt;/span&gt;&lt;/td&gt;                      
            &lt;/tr&gt;       

        &lt;/tbody&gt;    
        &lt;/table&gt;
</code></pre>
