stijn0713 Posted July 30, 2012 Share Posted July 30, 2012 How can i select the id of the div using the add image using jquery i tried something like this: $(document).ready(function(){ $('table td a.add').click(function(){ var form_id = $((this).parent() div).attr('id'); $content .= "<tr id =".$row_enquetes['ID'].">"; $content .= '<td>'.$row_enquetes['title'].'<a href="#" class="add"><img title="add" src="images/add.png"/></a><a href="#" class="delete"><img title="delete" src="images/delete.png"/></a>'; $content .= ' <div style="height:25px" class= "q_form" id="enq_"'.$row_enquetes['ID'].'"> <form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; $content .= ' <input type="hidden" name="ID_enquete" value="'.$row_enquetes['ID'].'" size="32" />'; $content .= ' <input type="text" name="new_question" value="" size="32" />'; $content .= ' <input type="submit" name="add_question" value="Voeg toe" />'; $content .= ' </form></div></td>'; $content .='</tr>'; Link to comment https://forums.phpfreaks.com/topic/266471-cannot-find-the-right-selector-for-use-in-jquery/ Share on other sites More sharing options...
requinix Posted July 30, 2012 Share Posted July 30, 2012 siblings() Or put the links inside the DIV. Link to comment https://forums.phpfreaks.com/topic/266471-cannot-find-the-right-selector-for-use-in-jquery/#findComment-1365534 Share on other sites More sharing options...
Mahngiel Posted July 31, 2012 Share Posted July 31, 2012 siblings() versus children(): <div class="parent"> <div class="child"></div> <div class="child"></div> </div> <div class="parent"> <div class="child"></div> </div> [*]There are two "parent" divs and 3 "child" divs. [*]The 'parent's are siblings of eachother [*]The 'child's are children of the 'parent's [*]The two 'child' divs in the first 'parent' are siblings of eachother, but not the third Link to comment https://forums.phpfreaks.com/topic/266471-cannot-find-the-right-selector-for-use-in-jquery/#findComment-1365564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.