jquery - Problem with :contains selector in IE8 -


i'm working on following selector in jquery:

$("div[id^=webpartwpq]:has(table.ms-sitedirresultssort) td:contains(' : ')").closest('div') 

in other words: select div id starting webpartwpq has table class ms-sitedirresultssort has td containing text :. @ end of question html rendered sharepoint.

the selector works under firefox 3.5, not under internet explorer 8. i'm testing using hide() function.

i've narrowed down td:contains(' : ') part of selector. running $("td:contains(' : ')") in firebug lite dumps out whole list of functions isn't valid. other selectors work fine in fb lite.

i've tried using jquery 1.3.2 , jquery 1.4rc1 without success. bug in jquery , if there ticket (i can't find one)? ideas on how best around this?

html:

<div style="" helpmode="1" helplink="/_layouts/help.aspx" allowdelete="false" class="ms-wpbody"     width="100%" id="webpartwpq4" haspers="false" webpartid="2ae67b12-82db-4238-8be9-cd4b39cbd15a">     <table cellspacing="0" cellpadding="0" border="0" width="100%" xmlns:crwp="urn:schemas-microsoft-com:categoryresultswebpart"         xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/xmlschema"         class="ms-sitedirresultssort">         <tbody>             <tr>                 <td width="100%" />                 <td nowrap="">                     <a href="#title">sort title </a><span>| </span><a href="#url">sort url </a>                 </td>             </tr>         </tbody>     </table>     <table cellspacing="0" cellpadding="0" border="0" width="100%" xmlns:crwp="urn:schemas-microsoft-com:categoryresultswebpart"         xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/xmlschema"         class="ms-sitedirresultspaging">         <tbody>             <tr>                 <td> : </td>             </tr>         </tbody>     </table>     <table cellspacing="0" cellpadding="0" border="0" width="100%" xmlns:crwp="urn:schemas-microsoft-com:categoryresultswebpart"         xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/xmlschema"         class="ms-sitedirresultsbody" id="table2">         <tbody>             <tr>                 <td valign="top">                     <img alt="" src="/_layouts/images/lstbulet.gif" />                 </td>                 <td width="100%" class="ms-sitedirresultstitle">                     <a href="http://site/cd10/_layouts/mysite.aspx?redirect=1">setup mysite</a>                 </td>             </tr>             <tr>                 <td />                 <td width="100%" class="ms-sitedirresultsurl">                     <a dir="ltr" href="http://site/cd10/_layouts/mysite.aspx?redirect=1">http://site/cd10/_layouts/mysite.aspx?redirect=1</a>                 </td>             </tr>         </tbody>     </table> </div> 

<td>     : </td> 

doesn't contain : in either browser, trailing newline different space. however:

<td> : </td> 

now give different results in ie , firefox. contains doesn't match in ie, because parser has silently thrown away whitespace, ie likes do. if @ innerhtml see:

<td>: </td> 

which unsurprisingly doesn't match selector.

so careful contains , whitespace because ie's html parser quirky ever.

personally i'd try avoid non-standard jquery selectors :has , particularly :contains, require jquery lot of slow work. standard css2-3 selectors, on other hand, can passed off browser's own selector engine in newer browsers selectors-api support (including ie8).

how like:

$('.ms-sitedirresultssort ~ table td').filter(function() {     return this.text().match(/(^|\s):(\s|$)/); }) 

~ css3 selector any-following-sibling; ie8 support it.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -