앵커 클릭시 자바 스크립트 스크롤이 작동하지 않음

스티브

내가 가진 이 자바 스크립트 파일 :

// .scroll to anchors 
jQuery(".scroll").on('click', function(e){
    e.preventDefault();
    var href = jQuery(this).attr('href');
    var hash = href.split('#');
    var url_hash = '#' + hash[1];
    if (jQuery(url_hash).length > 0) {
        var offset = (jQuery(window).width()<769) ? 20 : 65;
        jQuery('html, body').animate({
            scrollTop: jQuery(url_hash).offset().top-offset
        }, 1000);
    } else{
        location.href = href;
    }
});

다음 HTML이 포함 이 페이지의 대기열에 추가되었습니다 .

<ol>
    <li><a class="scroll" href="#one">How do I apply to work with you?</a></li>
    <li><a class="scroll" href="#two">Do I need to address selection criteria?</a></li>
    <li><a class="scroll" href="#three">Is there a closing date for applications for your positions?</a></li>
    <li><a class="scroll" href="#four">Who can I contact if I have any questions about one of your advertised positions?</a></li>
    <li><a class="scroll" href="#five">How will I know if my application for a position with you is successful?</a></li>
    <li><a class="scroll" href="#six">How do I find out the salary range of a position you have advertised?</a></li>
    <li><a class="scroll" href="#seven">Do you offer psychology supervision for new graduates?</a></li>
    <li><a class="scroll" href="#eight">Are you able to provide sponsorship for my visa?</a></li>
</ol>

<p><a id="one" name="one"></a></p>

<p><strong>How do I apply to work with you?
</strong><em><br>
All vacancies are advertised through the Current Vacancies section of our website. If you wish to express a general interest in working with us, we highly recommend you </em><a href="https://www.livehire.me/join/ors/careers"><em>join our Live Hire Talent Community</em></a><em>. We always have new opportunities, and will always look to our talent community before advertising. The best way to be at the front of the line for future and current vacancies is to take a moment to create a private web resume and join our livehire talent community.</em><a id="two" name="two"></a></p>

<p><strong>Do I need to address selection criteria?</strong><u> <br>
</u>
<em>No, you are not required to address any specific selection criteria to apply for a job.</em><a id="three" name="three"></a></p>

<p><strong>Is there a closing date for applications for your positions? </strong><em><br>
Most positions do not have a specific closing date, however some can be filled quite quickly, so we suggest you submit your application as early as possible.</em><a id="four" name="four"></a></p>

<p><strong>Who can I contact if I have any questions about one of your advertised positions?</strong><em><br>
You can contact our recruitment team at any time via </em><a href="mailto:[email protected]">[email protected]</a> <a id="five" name="five"></a></p>

<p><strong>How will I know if my application for a position with you is successful?</strong><a href="http://www.orsgroup.com.au/faq/how-will-i-know-if-my-application-is-successful/"><br>
</a><em>If you are shortlisted for an interview, you will receive a request to complete a recruitment assessment within 4 weeks of submitting your application. Due to the high volume of applications we receive, if you have not heard back from us within 4 weeks, you have been unsuccessful for the position.</em><a id="six" name="six"></a></p>

<p><strong>How do I find out the salary range of a position you have advertised?</strong><a href="http://www.orsgroup.com.au/faq/how-do-i-find-out-the-salary-range-of-a-position/"><br>
</a><em>We pay above award rates for all positions. Unfortunately our recruitment team are unable to give you an exact range as it is dependent on the skills, experience and qualifications of the successful applicant.</em><a id="seven" name="seven"></a></p>

<p><strong>Do you offer psychology supervision for new graduates?</strong><a href="http://www.orsgroup.com.au/faq/do-you-offer-psychology-supervision-for-new-graduates/"><br>
</a><em>Yes, we offer supervision arrangements, often as part of your offer of employment. You will need to discuss this with the hiring manager.</em><a id="eight" name="eight"></a></p>

<p><strong>Are you able to provide sponsorship for my visa?</strong><br>
<em>This is highly dependent on the position you are applying for, your skills, qualifications and experience and your location. If you require sponsorship, please make this clear in your application or email <a href="mailto:[email protected]">[email protected]</a></em></p>

그러나 링크를 클릭 할 때마다 브라우저는 스크롤 하지 않고 점프합니다.

링크를 클릭하면 브라우저가 앵커 태그로 스크롤하기를 원합니다.

JSfiddle .

감사합니다.

임부

당신을 위해 이것을 했어요 : https://jsfiddle.net/xox4ooaL/2/

js의 기능을 약간 변경하고 모든 링크와 항목을 잘라내어 데이터 속성을 사용하여 작동하는 방법에 대한 일반적인 아이디어를 제공했습니다. 또한 $는 Wordpress에서 작동하지 않지만 Wordpress에서 작업 할 때 다음과 같은 기능을 래핑합니다.

jQuery(document).ready(function($){
    // Do stuff
});

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

클릭시 앵커 스크롤이 작동하지 않음

분류에서Dev

자바 스크립트 '클릭'이 작동하지 않음

분류에서Dev

자바 스크립트에서 자동 클릭이 작동하지 않음

분류에서Dev

자바 스크립트 프로토 타입 변경 앵커 색상이 작동하지 않음

분류에서Dev

앵커 태그의 자바 스크립트 동적 생성이 작동하지 않습니다.

분류에서Dev

자바 스크립트 시계가 작동하지 않음

분류에서Dev

HTML / 자바 스크립트 클릭 카운터가 작동하지 않음

분류에서Dev

클릭 후 자바 스크립트 지연, 설정 시간 초과가 작동하지 않음

분류에서Dev

작동하지 않는 자바 스크립트를 사용하여 앵커 태그에 url.action 추가

분류에서Dev

자바 스크립트 이벤트가 ajax 호출시 작동하지 않음

분류에서Dev

클릭시 스크립트가 작동하지 않음

분류에서Dev

자바 스크립트에서 변경된 경우 iframe에 대한 앵커 대상이 작동하지 않음 (새 탭에서 열림)

분류에서Dev

PHP에서 생성 된 양식에서 자바 스크립트 클릭 기능이 작동하지 않음

분류에서Dev

앵커 태그는 작동하지만 부드러운 스크롤은 작동하지 않습니다. 페이지가 자바 스크립트가없는 것처럼 작동합니다.

분류에서Dev

사용자가 페이지 스크롤 (앵커)을 클릭하면 부트 스트랩을 호출하여 URL에 해시 링크를 표시합니다.

분류에서Dev

자바 스크립트 클릭 이벤트 만 페이지 새로 고침시 트리거가 작동하지 않음

분류에서Dev

자바 스크립트의 클릭 이벤트가 트리거되지 않음

분류에서Dev

자바 스크립트 클릭시 보이지 않는 div 표시

분류에서Dev

자바 스크립트 토글이 작동하지 않음

분류에서Dev

html 자바 스크립트 검색이 작동하지 않음

분류에서Dev

자바 스크립트 함수 IF 문이 작동하지 않음

분류에서Dev

자바 스크립트 탭 기능이 작동하지 않음

분류에서Dev

자바 스크립트 정규식이 작동하지 않음

분류에서Dev

HTTP 요청이 작동하지 않음 (자바 스크립트)

분류에서Dev

자바 스크립트 기능이 작동하지 않음

분류에서Dev

라디오 버튼을 클릭하면 이미지가 표시되지 않음-깨진 자바 스크립트

분류에서Dev

자바 스크립트 크기 컨트롤이 하위 페이지에서 작동하지 않음

분류에서Dev

진행률 표시 줄이 자바 스크립트 및 부트 스트랩에서 작동하지 않음

분류에서Dev

클릭시 자바 스크립트 라디오 버튼이 필드를 복사하지 않음

Related 관련 기사

  1. 1

    클릭시 앵커 스크롤이 작동하지 않음

  2. 2

    자바 스크립트 '클릭'이 작동하지 않음

  3. 3

    자바 스크립트에서 자동 클릭이 작동하지 않음

  4. 4

    자바 스크립트 프로토 타입 변경 앵커 색상이 작동하지 않음

  5. 5

    앵커 태그의 자바 스크립트 동적 생성이 작동하지 않습니다.

  6. 6

    자바 스크립트 시계가 작동하지 않음

  7. 7

    HTML / 자바 스크립트 클릭 카운터가 작동하지 않음

  8. 8

    클릭 후 자바 스크립트 지연, 설정 시간 초과가 작동하지 않음

  9. 9

    작동하지 않는 자바 스크립트를 사용하여 앵커 태그에 url.action 추가

  10. 10

    자바 스크립트 이벤트가 ajax 호출시 작동하지 않음

  11. 11

    클릭시 스크립트가 작동하지 않음

  12. 12

    자바 스크립트에서 변경된 경우 iframe에 대한 앵커 대상이 작동하지 않음 (새 탭에서 열림)

  13. 13

    PHP에서 생성 된 양식에서 자바 스크립트 클릭 기능이 작동하지 않음

  14. 14

    앵커 태그는 작동하지만 부드러운 스크롤은 작동하지 않습니다. 페이지가 자바 스크립트가없는 것처럼 작동합니다.

  15. 15

    사용자가 페이지 스크롤 (앵커)을 클릭하면 부트 스트랩을 호출하여 URL에 해시 링크를 표시합니다.

  16. 16

    자바 스크립트 클릭 이벤트 만 페이지 새로 고침시 트리거가 작동하지 않음

  17. 17

    자바 스크립트의 클릭 이벤트가 트리거되지 않음

  18. 18

    자바 스크립트 클릭시 보이지 않는 div 표시

  19. 19

    자바 스크립트 토글이 작동하지 않음

  20. 20

    html 자바 스크립트 검색이 작동하지 않음

  21. 21

    자바 스크립트 함수 IF 문이 작동하지 않음

  22. 22

    자바 스크립트 탭 기능이 작동하지 않음

  23. 23

    자바 스크립트 정규식이 작동하지 않음

  24. 24

    HTTP 요청이 작동하지 않음 (자바 스크립트)

  25. 25

    자바 스크립트 기능이 작동하지 않음

  26. 26

    라디오 버튼을 클릭하면 이미지가 표시되지 않음-깨진 자바 스크립트

  27. 27

    자바 스크립트 크기 컨트롤이 하위 페이지에서 작동하지 않음

  28. 28

    진행률 표시 줄이 자바 스크립트 및 부트 스트랩에서 작동하지 않음

  29. 29

    클릭시 자바 스크립트 라디오 버튼이 필드를 복사하지 않음

뜨겁다태그

보관