How do I check whether a certain div exist on my page and if not, redirect the visitor to another page?
How do I check whether a certain div exist on my page and if
Share
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 will need to use JavaScript to be able to check if the element exists and do the redirect.
Assuming the div has an id (e.g. div id=”elementId”) you can simply do:
If you are using jQuery, the following would be the solution:
Addition:
If you need to check the content of divs for a specific word (as I think that is what you are now asking) you can do this (jQuery):