내가 여러 입력을 가지고 가정,현재 활성 입력 옆에있는 입력에 액세스하는 방법은 무엇입니까?
<input type="text" name=ABC onkeyup='MyFunction(this)'>
<input type="text" name=ABC>
<input type="text" name=ABC>
function MyFunction(activeInput) {
/*... some code here to create array 'thisArray', of length 3 whose values are to be assigned to the 3 inputs. ...*/
activeInput.value = thisArray[0];
/*... this is where i need help. How do i assign the other 2 values to other 2 inputs...*/
}
이러한 입력에는 ID를 가지고,하지만 같은 이름을 가지고있다. JQuery도없고 Javascript 만 있습니다.
미리 감사드립니다.
당신은 당신이 달성하려고하는 것에 eloborate 수 있을까요? 당신이 쓰려고하는 코드는 정말로 뒤로 보이고 당신의 문제에 대한 더 똑똑한 해결책이있을 것입니다. –
나는 이미 존재하는 코드에 functionailty를 추가하려고 시도하고 있으며, 이것을 더 이상 설명 할 수 없습니다. getElementsByName이 트릭을했습니다. UR 시간을 가져 주셔서 감사합니다! – trinity
var siblings = Array.prototype.slice.call (activeInput.parentNode.getElementsByTagName ('input'))); – benastan