<div id="t">gf</div>
<div id="g">ds</div>
function $() {
return document.getElementById(arguments);
}
$('t', 'g').style.color = "red";
Is there something that I did wrong. It says cannot call style of null…
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 need to use the
applymethod to call a function using an an array as the arguments. The apply function also needs the context, so you need to passdocumentas well.Also,
getElementByIdonly accepts a single argument and returns a single element (AFAIK), so this is basically useless. Not to mention even if it did accept multiple arguments to return multiple elements, you still wouldn’t be able to use the resulting array in that manner.