안녕하세요 저는 자바 스크립트에 초보자입니다 ....
두 개의 선택 상자를 스크롤하여 첫 번째 선택 상자를 스크롤하면 다른 선택의 스크롤 막대 상자는 .... 스크롤 당신이 관련 요소에서 scrollTop 값을 읽어 스크롤 이벤트에 대한 이벤트 처리기를 만들고에 같은 값을 설정하는 것입니다 자바 스크립트 일반에다중 선택 상자에서 두 개의 스크롤 막대를 동기화
4
A
답변
14
$(document).ready(function(){
$('#one').scroll(function(){
var length = $(this).scrollTop();
$('#two').scrollTop(length);
});
});
2
두 번째 요소.
는var s1 = document.getElementById('Select1');
var s2 = document.getElementById('Select2');
function select_scroll(e) {
s2.scrollTop = s1.scrollTop;
}
s1.addEventListener('scroll', select_scroll, false);
0
내가 직면하고있는 문제는 난이 제 올라가있다 든가 하면요보기로 corrosponding 요소를 스크롤하는 제 1 선택 박스에서 요소를 선택 enabled.When 나 다중 선택 두 선택 박스가 .... 인 단일 선택은 모든 브라우저 탐색기, 파이어 폭스, 크롬에서 잘됩니다. 지금, 첫 번째 선택 상자에서 첫 번째 선택 상자의 마지막 요소를 선택하면 두 번째 선택 상자가 크롬 브라우저에서 마지막으로 선택된 요소로 스크롤되지 않습니다. 그러나 Internet Explorer 및 Firefox에서는 잘 작동하지만 Google 크롬 브라우저에서는 작동하지 않습니다. 내가 잘못한 곳이 어디인지 말해 주시고, 같은 일을하는 더 좋은 방법이 있습니까? 다음
는<html>
<head>
<script language="javascript">
function SyncListsL(){
for (var i = 0; i <= [document.puser.user_select.length]-1; i++) {
if(document.puser.user_select.options[i].selected == true)
{
document.puser.user_select2.options[i].selected=true; document.puser.user_select.options[i].selected=true;
}
else{
document.puser.user_select2.options[i].selected = false;
document.puser.user_select.options[i].selected=false;
}
}
}
function SyncListsR(){
for (i = 0; i <= [document.puser.user_select2.length]-1; i++) {
if(document.puser.user_select2.options[i].selected == true)
{
document.puser.user_select.options[i].selected=true; document.puser.user_select2.options[i].selected=true;
}
else{
document.puser.user_select.options[i].selected = false;
document.puser.user_select2.options[i].selected=false;
}
}
}
</script>
<title>scrollintoview</title>
</head>
<body bgcolor="e2dbc5">
<form name="puser" >
<table align="center">
<tr>
<td align="right" bgcolor="#eeeadd"> <font size=2>
<select name="user_select2" multiple size="5" onChange="SyncListsR()" style="width:35mm">
<option value="a1" title="a1">a1</option>
<option value="a2" title="a2">a2</option>
<option value="ab" title="ab">ab</option>
<option value="abc" title="abc">abc</option>
<option value="e1" title="e1">e1</option>
<option value="e2" title="e2">e2</option>
<option value="new" title="new">new</option>
</select>
</font></td>
<td align="left" bgcolor="#eeeadd"> <font size=2>
<select name="user_select" multiple size="5" onChange="SyncListsL()" style="width:50mm">
<option value="first" title="first">first</option>
<option value="last" title="last">last</option>
<option value="ghi" title="ghi">ghi</option>
<option value="User" title="User">User</option>
<option value="ed" title="ed">ed</option>
<option value="edit" title="edit">edit</option>
<option value="second" title="second">second</option>
</select>
</font></td>
</tr>
</table>
</form>
</body>
</html>
2
매우 간단하고, 난 그냥에서 작동 확인 FF 3.6
<form id=puser name=puser>
<select name=user_select1 onclick="document.puser.user_select2.selectedIndex = this.selectedIndex">
<select name=user_select2 onclick="document.puser.user_select1.selectedIndex = this.selectedIndex">
관련 문제
- 1. 두 개의 갤러리 동기화
- 2. 경고 대화 상자에서 다중 선택
- 3. 두 개의 BindingSource 동기화
- 4. 스크롤 막대를 스크롤보기로 클립
- 5. Android : 두 개의 서로 다른보기의 동기화 된 스크롤
- 6. C# : 두 개의 RichTextBox의 스크롤 위치를 동기화 하시겠습니까?
- 7. 두 스크롤보기를 사용하여 동기화 된 스크롤 수행
- 8. jQuery jScrollPane 스크롤 동기화
- 9. 두 개의 JTable에 대한 일반적인 스크롤 막대
- 10. CSS - 두 개의 막대를 나란히 놓습니다.
- 11. Visual Studio 2010에서 스크롤 막대 동기화
- 12. div의 스크롤 막대를 비활성화하십시오.
- 13. JPanel과에 스크롤 막대를 추가
- 14. 스크롤 막대를 아래쪽으로 내림
- 15. JQgrid : 두 개의 연결된 선택 드롭 다운
- 16. 은 두 개의 동일한 선택
- 17. Picturebox에서 스크롤 막대를 얻는 방법
- 18. 동일한 컴퓨터에서 두 개의 루비 스크립트 동기화
- 19. 두 개의 이미지 뷰 동기화 src
- 20. 매주 두 개의 MediaWikis를 동기화 하시겠습니까?
- 21. Android, 두 개의 ImageViews 투명도 동기화
- 22. 두 개의 별개의 mysql 데이터베이스 동기화
- 23. 두 개의 SQL Server 데이터베이스 동기화
- 24. 안드로이드 뷰 페이지 동기화 스크롤
- 25. Silverlight DataGrid 동기화 된 스크롤
- 26. wxpython 스크롤 패널 스크롤 막대를 업데이트하지 않음
- 27. 가로 스크롤 막대를 사용하여 패널 스크롤
- 28. 인접한 목록 상자에 스크롤 막대를 함께 연결
- 29. 다중 데이터베이스의 구조 동기화
- 30. 커서가 div를 움직일 때도 스크롤 막대를 감추기