- $(document).on('tap', '.editSearch', function(e) {
- // Trying to get the id of the previous element when the edit button is pressed
- alert($(this).prev().attr('id').toString());
- // Do some other stuff based on id I am trying to get ^here^
- });
So for example, if I click on the gear link button that is in the first list item, this should send an alert to the screen saying the id is "search1", but instead it is undefined. Basically, the attr() function in this case is ignoring the attributes I have set. If I change the attr('id') to attr('class'), it will show classes "ui-btn-inner ui-li ui-li-has-alt ui-corner-top" which I'm assuming is assigned automatically since I have two links in one list element, but once again the class "search" which I assigned, is not included in the result. Am I doing something wrong? Any suggestions would be greatly appreciated.