2012-02-27 3 views
0

셰어 포인트 페이지에서 각각 독립적으로 작동하는 두 개의 Jquery 기능이 있습니다. 그러나 함께 작동하도록하고 싶습니다. 'if'문을 작업에 대한 순서로 statisfied해야합니다. 예를 들어 일어난다. 올바른 목록 이름이 발견되고 해당 항목이 해당 목록에있는 경우 THEN은 해당 행을 숨 깁니다.두 개의 각각의 jquery 함수를 셰어 포인트로 결합합니다.

$(".ms-WPHeader").each(function(){ 

var valx = $(this).text(); 

    if(valx=="ListName"){ 
     alert("found"); 
    } 
}); 


$(".ms-vb-title").each(function(){ 

var val = $(this).text(); 

    if(val=="this item"){ 
     $(this).parents('tr:first').hide(); 

    } 
}); 

저는 Jquery를 처음 사용했지만 아직 구조가 새로운 것 같습니다. 도처에서 검색해 봤습니다. 도움을 받으시겠습니까? 이 같은

<td id="MSOZoneCell_WebPartWPQ2" valign="top"> 
<table width="100%" cellspacing="0" cellpadding="0" border="0" toplevel=""> 
<tbody> 
<tr> 
<td> 
<table width="100%" cellspacing="0" cellpadding="0" border="0"> 
<tbody> 
<tr class="ms-WPHeader"> 
<td id="WebPartTitleWPQ2" style="width:100%;" title="ListName"> 
<h3 class="ms-standardheader ms-WPTitle"> 
<a href="/test/Lists/Content%20List/AllItems.aspx" tabindex="0" accesskey="W"> 
<nobr> 
<span>ListName</span> 
<span id="WebPartCaptionWPQ2"></span> 
</nobr> 
</a> 
</h3> 
</td> 
<td valign="middle" style="width:10px;padding-right:2px;"> 
</td> 
</tr> 
</tbody> 
</table> 
</td> 
</tr> 
<tr> 
<td class="" valign="top"> 
<div id="WebPartWPQ2" style="" allowexport="false" allowdelete="false" width="100%" haspers="false" webpartid="9cc3ce88-c0c6-40d4-84a6-0a14d4bfe3ed"> 
<table width="100%" cellspacing="0" cellpadding="0" border="0"> 
<script> 
<tbody> 
<tr> 
<td> 
<iframeid="FilterIframe1" width="0" height="0" filterlink="http://dab:23292/test/Content%20Library/Template%20page.aspx?Filter=1&View=%7b9CC3CE88%2dC0C6%2d40D4%2d84A6%2d0A14D4BFE3ED%7d" title="Hidden frame to filter list" style="display:none" name="FilterIframe1" src="javascript:false;"> 
<table id="{33B3ECBF-66DA-41AD-811D-F3A2D7F644F7}-{9CC3CE88-C0C6-40D4-84A6-0A14D4BFE3ED}" class="ms-listviewtable" width="100%" cellspacing="0" cellpadding="1" border="0" dir="None" o:webquerysourcehref="http://dab:23292/test/_vti_bin/owssvr.dll?CS=65001&XMLDATA=1&RowLimit=0&List={33B3ECBF-66DA-41AD-811D-F3A2D7F644F7}&View={9CC3CE88-C0C6-40D4-84A6-0A14D4BFE3ED}" summary="Content Meta List"> 
<tbody> 
<tr class="ms-viewheadertr" valign="TOP" style="display: none;"> 
<tr class=""> 
<tr class="ms-alternating"> 
<td class="ms-vb2"> 
<td class="ms-vb2"> 
<td class="ms-vb-title" height="100%"> 
<table id="7" class="ms-unselectedtitle" height="100%" cellspacing="0" surl="" uis="512" cid="0x0100363A3EFC8C275E49B25A04F063C9FADB" ctype="Item" ms="0" csrc="" hcd="" couid="" otype="0" icon="icgen_gif||" ext="" type="" perm="0x7fffffffffffffff" dref="test/Lists/Content List" url="/test/Lists/Content%20List/7_.000" ctxname="ctx1" onmouseover="OnItem(this)"> 
<tbody> 
<tr> 
<td class="ms-vb" width="100%"> 
<a target="_self" onclick="GoToLink(this);return false;" href="/test/Lists/Content%20List/DispForm.aspx?ID=7" onfocus="OnLink(this)">this item 
</a> 
</td> 
<td class=""> 
</tr> 
</tbody> 
</table> 
</td> 
+0

일부 html 마크 업을 사용할 수 있습니까? 어떤 컨트롤이 클래스에 있는지 확실하지 않습니다. – Baz1nga

+0

안녕하세요 Baz1nga - 두 함수 모두

0

뭔가 :

추가 코드는 WPHeader 및 VB 제목 사이의 관계를 보여줍니다?

$(".ms-vb-title").each(function(){ 
    var val = $(this).text(); 
    if(val === "this item" && $(this).parents("ul").find(".ms-WPHeader").text() === "ListName") { 
     $(this).parents('tr:first').hide(); 
    } 
}); 

경우] :

var found = false; 
$(".ms-WPHeader").each(function(){ 
    if($(this).text() == "ListName") 
     found = true; 
}); 

$(".ms-vb-title").each(function(){ 
    if($(this).text() == "this item" && found == true) 
     $(this).parents('tr:first').hide(); 
}); 
+0

OptimusCrime에게 감사의 말을 전합니다 -하지만 웬일인지이 작업은 사실과 다르게 설정되었습니다 - 그래서 원하는 AND doesnt는 발생합니다 – daveybfire

관련 문제