엑셀 붙여넣기, 행/열을 반대로
페이지 정보
작성자 서방님 댓글 0건 조회 434회 작성일 21-03-10 16:16본문
<script src="http://code.jquery.com/jquery-latest.min.js"></script> <!--// 항상 최신 jquery 사용 //-->
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
</thead>
<tbody>
<tr>
<td><input type="text"></td>
<td><input type="text"></td>
<td><input type="text"></td>
</tr>
<tr>
<td><input type="text"></td>
<td><input type="text"></td>
<td><input type="text"></td>
</tr>
<tr>
<td><input type="text"></td>
<td><input type="text"></td>
<td><input type="text"></td>
</tr>
</tbody>
</table>
<script type="text/javascript">
<!--
$(document).ready(function () {
$('td input').bind('paste', null, function (e) {
$txt = $(this);
setTimeout(function () {
var values = $txt.val().split(/\s+/);
var currentRowIndex = $txt.parent().parent().index();
var currentColIndex = $txt.parent().index();
var totalRows = $('#example tbody tr').length;
var totalCols = $('#example thead th').length;
var count =0;
for (var i = currentColIndex; i < totalCols; i++) {
if (i != currentColIndex)
if (i != currentColIndex)
currentRowIndex = 0;
for (var j = currentRowIndex; j < totalRows; j++) {
var value = values[count];
var inp = $('#example tbody tr').eq(j).find('td').eq(i).find('input');
inp.val(value);
count++;
}
}
}, 0);
});
});
//-->
</script>
관련링크 (출처)
- https://jsfiddle.net/z4ut897p/ 154회 연결
댓글목록
등록된 댓글이 없습니다.
