I am currently trying to use the "jquery" search method for an object twice, but this does not allow me to do this, only the first instance of "find" works. Here is the code I would like to run ...
$("#phone_numbers > p:first-child").clone(true).insertBefore("#phone_numbers > span:last-child").find('.phone_type, .phone_number, .user_phones_id').val('').find('.delete_phone').remove();
The above code works fine, except for the last method "find", it does not delete elements with the class ".delete_phone".
However, if I changed the code to look like this ...
$("#phone_numbers > p:first-child").clone(true).insertBefore("#phone_numbers > span:last-child").find('.delete_phone').remove();
It deletes elements with the class ".delete_phone". I assume this is because I cannot use the find method twice in a row, but I'm not sure.
Does anyone know what is happening or is there a way to solve this problem?
Thanks!
source share