꼰대 개발자의 블로그
Home
  • 분류 전체보기 (180)
    • 이야기 (2)
    • Tools (2)
      • vs code (2)
    • Open API (82)
      • Jquery (47)
      • Naver (2)
      • Google (21)
      • Daum (4)
      • kakao (2)
      • 그 외 (6)
    • DataBase (28)
      • MS-SQL (22)
      • My-SQL (6)
    • Progmming (24)
      • ASP (1)
      • PHP (9)
      • .Net (7)
      • JSP (0)
      • HTML (0)
      • JAVA (0)
      • Python (2)
      • Javascript (4)
      • git (1)
    • CSS (1)
    • OS (15)
      • Microsoft (14)
      • Linux (0)
      • mac (1)
    • Cloud Server (3)
    • 추천 정보 (14)
    • 에러노트 (8)
블로그 내 검색

꼰대 개발자의 블로그

꼰대가 흐름을 따라가고 싶어서 기록하는 블로그

  • Open API/그 외

    유동적인 테이블 Td 셀 병합 rowspan 처리 Javascript 함수

    2021. 7. 22.

    by. Yo.

    지정 항목의 tr > td 값에 값이 동일 한 경우 rowspan 처리해주는 Javascript 함수입니다.

     

    주석 처리된 라인의 경우 contains 를 사용하여 포함된 조건이어서 일부 상황에서 정렬에 의해 해당  Row 사이에 다른 Row가 존재하는 경우 문제가 생길수 있는 상태인데

    원작자의 글 댓글에 일치하는 조건으로 코드 개선해주신분이 계셔서 취합했습니다.

     

    $(document).ready(function(e){
        genRowspan("td 클래스명");
    });
     
    function genRowspan(className){
        $("." + className).each(function() {
            //var rows = $("." + className + ":contains('" + $(this).text() + "')");
            var sText = $(this).text();
            var rows = $("." + className).filter(function() {
            	return $(this).text() == sText;
            });
            if (rows.length > 1) {
                rows.eq(0).attr("rowspan", rows.length);
                rows.not(":eq(0)").remove();
            }
        });
    }

     

    https://zero-gravity.tistory.com/311

     

    [jQuery] 유동적인 테이블 셀병합 - rowspan

     위와 같이 소속에 같은 데이터가 있을 경우 하나의 셀로 병합해주는 코드다. $(document).ready(function(e){ genRowspan("td 클래스명"); }); function genRowspan(className){ $("." + className).each(funct..

    zero-gravity.tistory.com

    https://api.jquery.com/contains-selector/

     

    :contains() Selector | jQuery API Documentation

    Description: Select all elements that contain the specified text. The matching text can appear directly within the selected element, in any of that element's descendants, or a combination thereof. As with attribute value selectors, text inside the parenthe

    api.jquery.com

     

    저작자표시 (새창열림)

    댓글

    관련글

    • 기상청 지역별 날씨정보 API 2022.01.27
    • Throttle & Debounce 스로틀과 디바운스 2021.09.06
    • 팝업 프린트 후 창 자동 닫기 2018.09.14
    • ip 주소로 국가 조회하는 방법 about.ip2c.org API 2018.08.30
    맨 위로
전체 글 보기
  • SyntaxHighlighter 웹버전
Tistory 로그인
Tistory 로그아웃
로그아웃 글쓰기 관리

Today

Total

Powered by ⓒ AXZ Corp.

Designed by Nana
블로그 이미지
Yo.

티스토리툴바