Given a structure like:
<div class="Stargate" id="MGM">
<div class="SG1">
</div>
<div id="Atlantis">
</div>
</div>
What will be SG1’s and Atlantis’ parent Stargate or MGM?
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.
There’s no difference, both
StargateandMGMis on the same parentdiv. But you’ll findMGMto be the “better” or “stronger” of the two ways of identifying thatdiv.With “better/stronger” I mean that the
idwill have implications in CSS/javascript, for example, in CSS the id is stronger.In javascript you have
where the
document.getElementByIdis widely supported whilst the correspondingdocument.getElementsByClassNameis a relatively new addition to modern browsers.