Is there a better way to write this so I don’t have to use the [0] and so I can access the text by the JQuery Text instead of innerText ? I don’t want to use innerText for Cross Browser compatibility .
$('#' + controlBestPractice)[0].innerText
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.
Use first if your selector returns more than one element (we don’t really know what is inside
controlBestPractice, e.g. it could be#div-id p):As bhamlin pointed out in comments, it appears that you are using id selector, so there should be only one element, so this should work: