업데이트 : 링크가 작동하지만 화살표는 여전히 문제가 있습니다. 당신이 행을 클릭하면 내가지도 아래 http://www.boulderdispensaries.com/Bind <td> (앵커가 포함되어 있지 않음, jQuery 사용)
에서 일하고 있어요
는, 당신은 그 아래 행이 표시를 참조하십시오. 행의 링크를 클릭하는 경우에도 마찬가지입니다. 또한 행을 클릭 한 다음 위의 행을 클릭하면 오른쪽 화살표가 거절되지 않습니다. 행을 클릭하면 링크로 이동하고 화살표가 제대로 작동하도록 어떻게 수정할 수 있습니까? 바이올리니스트를 들어
: 나는 또한 아래의 코드를 붙여 넣은 http://jsfiddle.net/yFkNf/
.
jQuery를 :
$(document).ready(function() {
var hideText='<img src="arrow-down.gif" width="10" height="10" border="0" alt="v">';
var showText='<img src="arrow-right.gif" width="10" height="10" border="0" alt=">">';
var is_visible = false;
$('tr:odd td').addClass('expand');
// this is the hack I was using to get the links to work, but then the bind doesn't
// $('tr:odd td:nth-child(1)').removeClass('expand');
// $('tr:odd td:nth-child(2)').removeClass('expand');
// $('tr:odd td:nth-child(4)').removeClass('expand');
$('tr:odd td:first-child').prepend('<a href="#" class="toggleLink">'+showText+'</a> ');
$('.toggle').hide();
$('a.toggleLink').click(function() {
is_visible = !is_visible;
$(this).html((!is_visible) ? showText : hideText);
$(this).parent().parent().next('tr').toggle();
return false;
});
$('.expand').click(function(){
is_visible = !is_visible;
$(this).parent().find('a.toggleLink').html((!is_visible) ? showText : hideText);
$(this).parent().next('tr').toggle();
return false;
});
});
여기에 매 2 행의 형식의 다음 TD까지 버블 링에서 TD 내부 앵커 링크 클릭을 방지 할 수
<tr>
<td><a href="http://www.boulderkindcare.org/">Boulder Kind Care</a></td>
<td><a href="http://maps.google.com/etc">2031 16th</a></td>
<td>(720) 235-4232</td>
<td><a href="mailto:[email protected]"><img src="email_icon.gif" /></a></td>
<td nowrap="nowrap"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr class="toggle">
<td colspan="8">More info coming soon.</td>
</tr>
'return false '는 기본적으로 "평상시에하지 않을 일을하지 마십시오"라는 의미입니다. 링크의 경우 브라우저가 해당 링크를 따르지 못하게합니다. 그러나 테이블 행이나 데이터 셀에는 기본 클릭 동작이 없으므로 'return false'는 기본적으로 의미가 없습니다. –
맞아, 나는 그의 a.toggleLink 핸들러를 언급하고 있었다. –
감사합니다! 나는 is_visible을 피하는 것을 끝내었다. – Zade