JavaScript link a button to a part of another page button link to part of page

I have a link button that goes to another page, it works, but i want the link to go to a spicific part of that page. i know i should use jquery for thisand for some reason its not jumping to the section i want it to jump to.

My button link:

 <div class="btn_holder top-slide"><a 
  target='_blank' href="http://testurl.com/media#isabelo"><p class="leeu_button">READ
  MORE</p></a>
 </div>

What i currently have srolls to bottom of page and not to the section where id="isabelo". so this jquery works but its not what i want. hope you understand.

$(document).ready(function(){ 

//check if hash tag exists in the URL
if(window.location.hash) {          
    $("html, body").animate({ scrollTop: $(document).height() }, 1000);
    1000);      
}     });

I have also already tried this (not working at all) :

$(document).ready(function(){ 

//check if hash tag exists in the URL
if(window.location.hash) {          
     $('html, body').animate({ scrollTop: $("#isabelo").offset().top }, 1000);      
}
     });

the page im trying to link to has a div with a id="isabelo"

<div class="content_holder terms_row" id="isabelo">
Answer:1

My solution to this:

$(document).ready(function(){    
//check if hash tag exists in the URL
if(window.location.hash) {   
setTimeout(function(){
     $('html, body').animate({ scrollTop: $("#isabelo").offset().top },
 1000); 
 },1000);       
  }      
}); 

used the time-out funtion to load it bit later. Solved :)

Answer:2

You shouldn't need jquery for this. You should be able to link to "media/pagename.html#isabelo" with straight HTML. But you are missing the page name. That, and you need to have a NAME tag on there as well as the ID.

Answer:3

Well I tried that in the same page and it worked. I'm not an expert in jquery but if:

 $("html, body").animate({ scrollTop: $(document).height() }, 1000);

works but with isabelo not, maybe is because the browser hasn't still loaded the html where isabelo is. Try to debug to see if you have that isabelo element in that point or it is not still loaded.

Other different thing I found is that in the first example you put twice the "1000"

$("html, body").animate({ scrollTop: $(document).height() }, 1000); 1000);

in the second not

$('html, body').animate({ scrollTop: $("#isabelo").offset().top }, 1000);

But I supose it was a mistake of copy/paste, because in the first example I don't find the sense of it but it works as u said.

Answer:4

I have the following Javascript string that represents a moment in time in Coordinated Universal Time (UTC): myUTCString = "2014-11-06 00:00:00"; I want to use moment.js to convert this string to a ...

I have the following Javascript string that represents a moment in time in Coordinated Universal Time (UTC): myUTCString = "2014-11-06 00:00:00"; I want to use moment.js to convert this string to a ...

  1. convert string into int
  2. convert string into array
  3. convert string into list
  4. convert string into json
  5. convert string into date
  6. convert string into array javascript
  7. convert string into integer
  8. convert string into int python
  9. convert string into datetime python
  10. convert string into int c++
  11. convert string into json object
  12. convert string into int java
  13. convert string into number javascript
  14. convert string into datetime
  15. convert string into float python
  16. convert string into dictionary python
  17. convert string into array python
  18. convert string into byte array
  19. convert string into double java
  20. convert string into json python

When I click on the button labeled "Continents & Oceans," a dropdown list appears - but only if I click on the button twice. I'd like it to work with the first click. Is there something wrong ...

When I click on the button labeled "Continents & Oceans," a dropdown list appears - but only if I click on the button twice. I'd like it to work with the first click. Is there something wrong ...

I want to draw something like a donut, so a circle with a hole in the middle. I tried using ctx.clip(), but I realized it limits the path to inside, and I want it to limit the path to the outside. ...

I want to draw something like a donut, so a circle with a hole in the middle. I tried using ctx.clip(), but I realized it limits the path to inside, and I want it to limit the path to the outside. ...

  1. javascript canvas draw circle
  2. javascript canvas draw line
  3. javascript canvas draw image
  4. javascript canvas draw rectangle
  5. javascript canvas draw text
  6. javascript canvas draw pixel
  7. javascript canvas draw polygon
  8. javascript canvas draw point
  9. javascript canvas draw triangle
  10. javascript canvas draw with mouse
  11. javascript canvas draw filled circle
  12. javascript canvas draw image from file
  13. javascript canvas draw png
  14. javascript canvas draw grid
  15. javascript canvas draw ellipse
  16. javascript canvas draw dashed line
  17. javascript canvas draw rounded rectangle
  18. javascript canvas draw image from url
  19. javascript canvas draw arrow
  20. javascript canvas draw svg

I'm using Sly Slider with a free wordpress theme. I've enqueued properly the js file, set the html markup and wrote a jquery function according to the documentation but cannot to seem to get it to ...

I'm using Sly Slider with a free wordpress theme. I've enqueued properly the js file, set the html markup and wrote a jquery function according to the documentation but cannot to seem to get it to ...

  1. slider initial bracelet
  2. slider initial value
  3. initialize slider jquery
  4. initialize slider
  5. initial slider necklace
  6. initialize slider bootstrap
  7. slick slider init
  8. slick slider initialize
  9. slick slider init event
  10. slick slider initialslide
  11. slick slider initialize on click
  12. slick slider init not working
  13. slick slider init function
  14. slick slider init event not working
  15. slick slider init not firing
  16. slick slider initialize event
  17. slick slider init callback
  18. jquery slider initial value
  19. swiper slider init
  20. slick slider initialize hidden