Checking if a selector and a method combination worked
I want to test if something was successfully appended because I do not know if the selector worked (actually selected anything or even was a valid selector).
I read that you can test if a selector worked with
- if ( $('#someDiv').length ){
- }
But would this also work for
- if ( $('#someDiv').append('<p>appended</p>').length ){
- }
Or do I need to do a plain selection first without a chained function, and then append, as in the first example?