이전 형제의 이름을 알아야합니다.이전 형제 이름을 얻는 방법
<table id="sort">
<tr name="nodrag nodrop">
<td colspan=3><strong><a style="cursor:pointer;" class="toggle">Group 1</a></strong> </td>
<td style="text-align: right;"><a class="button3" href="#" ><span> Edit </span></a> <a class="button3" href="#" ><span> Delete </span></a></td>
</tr>
<tr id="1" class="tr_group"'>
<td style="width:10px;" class="dragHandle"> </td>
<td><a href=# style="margin-left: 20px;">Umair Iqbal</a></td>
<td><span style="font-size: 12px; color: #999; line-height: 100%;">A Student at TUM</span></td>
<td style="text-align: right;"><a class="button3" href="#" ><span> Edit </span></a> <a class="button3" href="#" ><span> Delete </span></a></td>
</tr>
IST에 행이 두 번째 행의 이전 형제입니다 : 간단하게하기 위해 나는 몇 가지 예제 코드를
<html>
<head>
<script type="text/javascript">
function myFunction()
{
var itm=document.getElementById("item2");
alert(itm.previousSibling.name);
}
</script>
</head>
<body>
<p name='pn'>paragraph</p>
<button id='item2' onclick="myFunction()">Try it</button>
</body>
</html>
편집을해야합니다. 다음과 같은 기능을 사용할 필요가 자바 스크립트 정기적으로
$('#item2').prev().attr("name");
(에 : 나는 jQuery를 사용
감사
자바 스크립트 함수에 전달하는 요소는 무엇입니까? –
실제 상황에 맞게 코드를 변경하겠습니다. –
안녕하세요, getpreviousSiblingName (document.getElementById ("item2")) 호출 코드를 업데이트했습니다. –