I have two Jquery functions that each work independently on a sharepoint page – however I’d like for them to work together – both ‘if’ statements must be statisfied in order for an action to take place e.g. IF the right list name is found AND the right item is in that list THEN hide that row.
$(".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();
}
});
I’ve new to Jquery and still new to the structure – I’ve searched everywhere – hope you can help?
Additional code snippet shows relationship between WPHeader and vb-title:
<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>
Assuming that ms-vb-title is the class name of list items and ms-WPHeader is inside this list somewhere, here is the proper code:
If the element with class ms-WPHeader is outside the list but the amount match the amount of lists, you can try with
index():Edit: seeing your actual markup, here is something that should work better:
Edit: assuming you got amount of
.ms-WPHeaderequal to.ms-vb-titleand in same order, you can use the index: