How can you get an element before its added to the DOM (before append())
$('#enclosure_balance'+id).css({background:'red'})
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.
As far as I know, the only way is by reference if you control or have access to the construction of it.
Reference the variable / property which contains it. Since it hasn’t been appended it’s not accessible via the DOM methods.
If you want the element to be visibly hidden just append it to a container element that has offsetting css values ( eg position absolute, top -999em, left -999em )
EDIT: There are also document fragments: http://ejohn.org/blog/dom-documentfragments/#postcomment but since they’re not in the document itself, you can’t reference the elements inside with
document.getElementByIdand such.