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

Open API/그 외 |2021. 7. 22. 10:22
반응형

지정 항목의 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

 

댓글()

jQuery 여러개의 Class가 적용된 객체 선택하기

Open API/Jquery|2018. 11. 29. 10:50
반응형

How can I select an element with multiple classes in jQuery?

- without space.

여러개의 클래스가 지정된 객체를 선택하고자 할 때.. 어떻게 해야할까

- 띄어쓰기 없이 해야함.

<span class="a b c">multiple classes</span>


$(".a.b.c").trigger("click")




댓글()

중국에서 Google map 실행이 안되는 경우 해결 방법

Open API/Google|2018. 10. 23. 14:42
반응형

중국내에서 Google map 실행이 안되는 경우 해결 방법


원인은 https 접속이 안되기 때문이고 

이 문제는 Google map FAQ에서 해결 방법을 제시해주고 있습니다.



아래 내용은 Google Map FAQ의 일부 발췌한 내용입니다.


Google Maps Platform products are served within China from the domain maps.google.cn. This domain does not support https. When making requests to Google Maps Platform products from China, please replace https://maps.googleapis.com with http://maps.google.cn.



중국에서 https://maps.googleapis.com 접속이 정상적으로 이뤄지지 않기 때문에


http 통신을 해야하고 중국내에서 이용할 수있는 도메인은 http://maps.google.cn 


아래와 같이 Google Map API javascript 파일 참조시에 도메인을 변경해줍니다.



<script src="http://maps.google.cn/maps/api/js?key=YOUR_API_KEY"
type="text/javascript">
</script>



내용이 변경될 수 있기 때문에 Google Map FAQ 링크를 함께 남깁니다.


https://developers.google.com/maps/faq#china_ws_access

댓글()