사용자가 다음 버튼을 클릭 할 때 두 함수는 next() 및 fbsharing() 함수를 호출합니다. http://jsfiddle.net/U3jdm/onclick을 실행하려면 두 개의 함수가 필요합니다.
<div id="content" style="width:60%; float:left; padding: 10px 10px 10px 10px;">
<div id="ncholder">
<div id="ncframe"></div>
<div class="PortSwap" id="swap0">
111111111111
</div>
<div class="PortSwap" id="swap1">
2222222222
</div>
<div class="PortSwap" id="swap2">
333333333
</div>
<div class="PortSwap" id="swap3">
4444444444
</div>
</div>
<div id="ncnav" style="width:83%; float:left; padding: 30px 10px 10px 10px;">
<div style="width:30%; float:right; color:#66ce9d; font-size:18px; font-weight:bold;">
<div style="width:30px; height:30px; float:left;"><img src="leftnav.png" alt="Previous" onClick="(function(){prev(); fbSharing();})();"/></div>
<div style="width:30px; height:30px; float:right;"><img src="rightnav.png" alt="Next" onClick="(function(){next(); fbSharing();})();"/></div>
</div></div>
<div id="fbshare" style="color:#ed1a64; font-size:18px; font-weight:bold;"> </div>
</div>
<script>
$(function() {
"use strict";
$('.PortSwap').hide().eq(0).addClass('active').show();
});
function prev() {
var current = $('.PortSwap.active'),
prev = current.prev('.PortSwap');
console.log(prev.length, prev);
if (prev.length) {
current.hide().removeClass('active');
prev.addClass('active').show();
}
}
function next() {
var current = $('.PortSwap.active'),
next = current.next('.PortSwap');
if (next.length) {
current.hide().removeClass('active');
next.addClass('active').show();
}
}
function fbSharing() {
var test = document.getElementByClassName("PortSwap active");
var share;
var testid = test.id;
if (testid = 'swap0') {
share ="1111111";
}
else if (test.ID = 'swap1') {
share ="2222";
}
else if (test.ID = "swap2") {
share ="33333";
}
else if (test.ID = "swap3") {
share ="44444";
}
document.getElementById("fbshare").innerHTML=share;
}
</script>
: 한 번에 (WORKING) fbsharing에 하나가 표시됩니다 4 명 div의 사이 다음 스왑 (사업부 아이디 = fbshare에서 사용자 정의 공유 버튼이 표시됩니다 (FAIL)은 여기
내 jsfiddle입니다 .
안녕하세요, 두 기능의 작동 데모를 들어 getelementsclassname에 내 실수에 얼룩을지게 주셔서 감사합니다 는 여기있다, onclick을 실행중인 : http://jsfiddle.net/79B8z/1/
당신은'GetElementsByClassName'과 S를? :) –
안녕하세요, "배열 인덱스 표기법을 사용해야 할 수도 있으므로 첫 번째 HTMLElement 컬렉션을 반환합니다"지금은 의미가 있지만 그 STUPID mistake.now를 발견해 주셔서 감사합니다. 그것은 올바르게 작동합니다. –
@ChrisPin [HTMLCollection] (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection) ... Robert : 아마's'가 있지만'G'는 없을 것입니다;). – Teemu