플러그인 코드가 있습니다.

function add_neori_social_share_buttons_icons($atts){ global $post; $url = get_permalink($post->ID); $url = esc_url($url); $media = wp_get_attachment_url( get_post_thumbnail_id($post->ID)); $media = esc_url($media); $description = get_the_title($post->ID); $description = esc_html($description); $html = $html . "<a target="_blank" href="http://www.facebook.com/sharer.php?u=" . $url . ""><div class="icon-social-facebook col"></div></a>"; $html = $html . "<a target="_blank" href="https://twitter.com/share?url=" . $url . ""><div class="icon-social-twitter col"></div></a>"; $html = $html . "<a target="_blank" href="mailto:?subject=I wanted to share this post with you from&body=" . $url . ""><i class="fa fa-envelope-o"></i></a>"; $html = $html . "<a onclick="myFunction()" href="JavaScript:void(0)"><i class="fa fa-print"></i></a>"; $html = $html . "</div>"; return $content = $content . $html; } add_shortcode("neori-social-share-icons", "add_neori_social_share_buttons_icons"); 

포스트 섹션에 4 개의 아이콘이 표시되지만 마지막 인쇄 아이콘에 대한 것입니다. 내가 무엇을하든 앵커 태그의 onclick 속성을 입력하지 않습니다.

여기 4 개의 아이콘에 대한 게시물 URL이 있습니다.

http://mandybright.promogent.com/victims-of-the-border-husband-of-u-s-citizen-wife-disappears-after-desert-crossing/

댓글

  • 더 의미가 없습니까? ID 또는 html 클래스를 추가 한 다음 대기열에 추가 된 자바 스크립트 파일에서 jQuery(".onprint").click( ... )와 같은 작업을 수행합니까? onClick 핸들러는 나쁜 습관이며 100 % 피할 수 있습니다. ' 단축 코드에 자바 스크립트를 직접 넣을 필요가 없습니다

답변

WP가 콘텐츠에서 onclick을 제거하고 있다고 생각합니다. 어쨌든 인라인 onclick을 사용해서는 안됩니다.

링크에 ID를 부여한 다음 JS에서 on click을 추가하세요. 이와 같은 …

jQuery("#myLink").click(function() { ... Your myFunction() code }); 

댓글

  • 해결해 주셔서 감사합니다.

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다