css - What jQuery selector can I use to match these HTML elements (requires ":contains()")? -


I am trying to find a jQuery selector which will only match the element that is directly contained in "PDT" Example (short for short):

  & lt; Div & gt; & Lt; P & gt; & Lt; Strong & gt; (07-27) 21:28 PDT San Francisco & lt; / Strong> - San Francisco observers have ended more than a decade ... & lt; / P & gt; & Lt; P & gt; 10-1 votes, supervisor Chris Daily dissatisfaction only & lt; / P & gt; & Lt; / Div & gt;  

and

  & lt; Div & gt; & Lt; P & gt; (07-28) 08:59 PDT Washington - & lt; / P & gt; & Lt; P & gt; Order of American factories of large ticket manufactured goods fell ...  

In the first case, this & lt; Strong> , and in the second case, the first & lt; P & gt; . I am looking for the same selector who will match both, or many selectors, who will not be able to find any false positives.

By my analysis, I know the following things about those elements that will match:

  • They either have a & lt; P & gt; or
  • The child of their parents
  • contains the "PDT" text
  • their Do not have any children.

    Looking at all of these features, I think that there will be a jQuery selector, which will meet these elements with high accuracy, and no false positives will occur. However, I have some problems, as I have not used a complex selector.

    I know that the tools (related to each document):

    • Not sure that the last one would be useful - I just read more of the document carefully and noticed that the text nodes are considered: the empty selector, so the HTML element that I'm trying to target is actually empty is not. However, I can count on the fact that they have only one text node, and nothing else will happen.

      My first shot was:

        *: In it (PDT): first-child: empty  

      but that does not work having had. I have tried many other changes, but I am like stumped. Can anyone guide some?

      A Warning: I'm not actually using jQuery in my script, but rather its selector engine, so I have to try to do all this in a selector, and I do not use jQuery methods As can Find () and .filter ()

      Thanks in advance for any help!

By using all your parameters, you can:

< Strong> Try it:

  var $ result = $ (': first-child: no (: (*)): contains ("PDT") ;  

Take note of the empty space around "PDT".

If they keep the lesson they will return it, the first child, and you do not have any other hair tag.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -