Should i make such check, before detaching?
if(for_detach.parent().length) {for_detach.detach();}
or jquery automatically do it?
Thanks 😉
Update
Same with wr.find('iframe:hidden').show(); and different others situations.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can always have a look at the source code.
In case of
detach:So yes, jQuery will make sure that there is a parent before it detaches from it, but it does not ignore the call.
It depends on the function whether calling it twice has any effect.
Of course if you call
showtwice then the second call will not have any (visible) effect. But that does not mean that jQuery is not doing anything in the back. Have a look at theshowimplementation.