테스트 사이트 - 개발 중인 베타 버전입니다

td의 값이 없으면 해당 tr의 특정td값 안보이게 채택완료

인찌 3년 전 조회 4,131

table 이구여 tr이 많습니다!

#answer_aq 에 값이 없을경우 

.table_input_radio label 의 내용을 dispaly:none 하고싶습니다!

방법이 있을까요?ㅠ

 

</strong></p>

<p><tr class="tabletr"></p>

<p>                <td class="table_input_radio"></p>

<p>                    <label><input type="checkbox" name="service_end_data"><em></em></label></td></p>

<p>                <td>07</td></p>

<p>                <td></p>

<p>                    <select></p>

<p>                    </select></p>

<p>                </td></p>

<p>                <td id="answer_aq"></p>

<p>                   </p>

<p>                </td></p>

<p>            </tr></p>

<p><strong>

댓글을 작성하려면 로그인이 필요합니다.

답변 6개

채택된 답변
+20 포인트
3년 전

</p>

<p>tr이 많습니다! <-- 이 말은 <span class="token operator"><</span>td id<span class="token operator">=</span><span class="token double-quoted-string string">"answer_aq"</span><span class="token operator">> 이것이 여러개 나온다는 것인데 </span></p>

<p><span class="token operator">   id=~~이렇게 여러번 사용할 수 없습니다</span></p>

<p>같은 answer_aq가 많으면 다음처럼 class를 써야합니다</p>

<p><span class="token operator"><</span>td class<span class="token operator">=</span><span class="token double-quoted-string string">"answer_aq"</span><span class="token operator">> </span></p>

<p> </p>

<p>자바스크립트는 다음과 같이</p>

<p><script>

$('.answer_aq').each(function(){

      if( !$.trim( $(this).text() ) ) $(this).siblings().eq(0).children().hide();

});

</script></p>

<p>

 

 

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

폭주죽
3년 전
좋은답변이네요!
인찌
3년 전
우와 너무 감사합니다ㅠㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

php로 할 수 없는 상황인가요?

 

<tr class="tabletr">
                <td class="table_input_radio">
                    <label><input type="checkbox" name="service_end_data"><em></em></label></td>
                <td>07</td>
                <td>
                    <select>
                    </select>
                </td>
                <td class="answer_aq">
                   
                </td>
            </tr>

 

 

$(function(){
 $('td.answer_aq').each(function() {
  var contents = $.trim($(this).html());
  if(contents.length<1) {
    $(this).parent('tr').find('td.table_input_radio>label').hide();
  }
  });
});
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

</p>

<p><table>

    <?php if($data == null){?>

    <tr>

        내용        

    </tr>

    <?php }?>

</table></p>

<p>

 

이런식으로 <tr>을 조건문으로 감싸면 될것 같습니다.

 

안보여야 하는 부분이 <td>라면 colspan부분도 생각하셔야 하겠죠.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

포이치
3년 전

</p>

<p>$(function(){

 $('td[id="answer_aq"]').each(function() {

  var contents = $.trim($(this).html());

  if(contents.length<1) {

    $(this).parent('.tabletr').children('.table_input_radio>label').hide();

  }

  });

});

 

tr 값이 많군요. 위 스크립트로 적용해보세요.

그리고 W3C 사양에 id값이 중복되는건 옳지 않습니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

인찌
3년 전
아구 왜 안될까여ㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

포이치
3년 전

</p>

<p><table>

<code><tr class="tabletr"> <td class="table_input_radio"> <label><input type="checkbox" name="service_end_data"><em></em></label></td> <td>07</td> <td> <select> </select> </td> <td id="answer_aq"> </td> </tr></code></p>

<p><code></table></code></p>

<p> </p>

<p><code><script></code></p>

<p>function check_td(td_id){

  var contents = $.trim($(td_id).html());

  if(contents.length<1) return false

  else return true;

}



$(function(){

  if(!check_td('#answer_aq')) {

    $('.table_input_radio>label').hide();

  }

});</p>

<p><code></script></code></p>

<p>

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

인찌
3년 전
감사합니다! 그런데 #answer_aq에 값이 있을 경우에는.table_input_radio label의 내용이 보여야하는데 전부 없어집니다ㅠ

댓글을 작성하려면 로그인이 필요합니다.

3년 전

$(document).ready(function() {

  if ($('#answer_aq').text() == '') {

    $('.table_input_radio label').hide()

  }

});

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

인찌
3년 전
처음에 저도 이렇게했는데 전체가 없어지더라구요!ㅠ
tr마다 적용이 되어야합니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인