Is there anyway I can use a php variable in the JQuery script?
Example:
- PHP variable:
$sr2 - Excerpt of JQuery script (with variable):
$('#a2_bottom_$sr2')
How can I make it so the variable is valid in that JQuery part?
Thanks
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.
What you could simply do is use your PHP to echo out the code to initiate a JavaScript variable.
Once the PHP code is parsed, and the HTML is sent to the user – all they will see is the result of the PHP echo –
Now your
phpVariableis available to your JavaScript! So you use it like you would in any other case –That will retrieve us any
<div>element with afooclass –