슬라이더 기반의 이미지 갤러리를 구축하고 자바 스크립트를 통해 새로운 이미지를로드하며 자바 스크립트를 통해 Google +1 버튼의 URL을 설정해야하므로 각 이미지에 +1을 설정할 수 있습니다. .자바 스크립트로 Google +1 버튼 URL 설정
또한 각 이미지에 따라 +1 버튼을 다시로드해야합니다 (URL에 고유 한 이미지 ID가 포함 된 쿼리 문자열 매개 변수가 있음). 이것이 가능한가?
슬라이더 기반의 이미지 갤러리를 구축하고 자바 스크립트를 통해 새로운 이미지를로드하며 자바 스크립트를 통해 Google +1 버튼의 URL을 설정해야하므로 각 이미지에 +1을 설정할 수 있습니다. .자바 스크립트로 Google +1 버튼 URL 설정
또한 각 이미지에 따라 +1 버튼을 다시로드해야합니다 (URL에 고유 한 이미지 ID가 포함 된 쿼리 문자열 매개 변수가 있음). 이것이 가능한가?
<!-- Place this tag where you want the +1 button to render -->
<div class="g-plusone" data-annotation="inline" data-href="#"></div>
<!-- Place this render call where appropriate -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
당신은 jQuery를 사용하여 gplus의 HREF 속성을 변경하려면 다음 코드를 사용할 수 있습니다. 먼저 jQuery 라이브러리를 반드시 확인하고 아래의 코드를 사용 head 태그에
<script type="text/javascript">
jQuery(".your-button").click(function(){
jQuery(".g-plusone").attr("data-href","Your-Value-Goes-Here");
});
</script>
쓰기이 :
// Load +1 script
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
HTML 코드 :
<div id="plusone_container">
</div>
을 그리고 어디서든이 jQuery를 쓰기 +1 버튼의 URL을 설정하고 싶습니다.
$("#plusone_container").html('<div id="plusone"></div>');
gapi.plusone.render("plusone", { "href": "Your URL" });