Here is my JSFiddle. I want the url as http://example.com/#content-1 and update to next h2 title when i click next. Any help please ?
Here is my JSFiddle . I want the url as http://example.com/#content-1 and update to
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.
Here’s a really quick solution without changing too much of your codes:
Javascript
~UPDATE01 090912~
OP has asked, “Can you tell me please how to get the same content even after refresh the page ? – user1619228 1 hour ago”
You can do this by adding this right after
function setActive(i) { // codes }:The additional script above simply:
same content as the variable, or in an indirect way, the URL’s
hashtag
back to the div that contains the same content as the variable, or
in an indirect way, the URL’s hash tag (fragment identifier)
I have not addressed the updating of the image’s background colour yet, but I believe that if you apply the fundamentals demonstrated above, you’d be able to add the “selected” classes to the right images as well. You’d of course be required to tweak the codes a little by adding some additional IDs or classes to the list items holding the images in order to manipulate them via jQuery.
I know the above may not be the prettiest or the best of solutions, but it’s the only one that came to mind when I imposed a restriction on myself not to change too much of your HTML structure or jQuery.
Hope this helps further!
UPDATE02 090912
Further reference for OP
Here’s how the whole document should look like:
WHOLE DOCUMENT
Just copy and paste everything into a new HTML file and open it up in a browser of your choice, click on next and refresh. The page content that is shown should remain the same. Copy the new URL, open up a new tab and throw the copied URL into the address bar – the page loads and shows the correct content based on the hash tag.