문제

나는 해결 된 문제에 대해 단순한 질문이 있지만 내 환경에서는 해결책이 작동하지 않습니다.

SharePoint에는 열이있는 테이블이 있습니다. 컨텐츠의 콘텐츠가 "녹색"과 같을 때 단일 TD의 배경색을 녹색으로 변경하고 싶습니다.

나는 이것을 시도했다

<table>
    <tr>
        <table>
            <tr>
                <th width="200px">Title</th>
                <th width="100px">State</th>
            </tr>
            <tr>
                <td>Hello</td>
                <td>Green</td>
            </tr>
            <tr>
                <td>World</td>
                <td>Red</td>
            </tr>
        </table>
    </tr>
</table>
<script>
    $("td:contains('Green')").css('background-color', '#00FF00');
</script>

jsfiddle에 대한 나의 예

그러나 이것은 SharePoint 테이블 인 테이블 구조에서 작동하지 않습니다. 왜요? 문제는 무엇입니까? 전체 테이블은 마지막 값의 색상으로 페인트입니다.

도움이 되었습니까?

해결책

먼저 jQuery 파일을 포함합니다

그러고 나서

코드를 작성하십시오

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>

<script>
$(document).ready(function(){
$("td:contains('Green')").css('background-color', '#00FF00');
});
</script>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top