JQuery contains exact search

后端 未结 2 874
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 06:40

I\'m using JQuery to parse some xml and having trouble with the line below:

$(xml).find(\"ACT:contains(\" + selectedAct + \")>SCENE\").each(function()


        
相关标签:
2条回答
  • 2021-01-15 07:08

    You could try extending the selectors... I made a demo in my blog a while back.

    $.extend($.expr[':'],{
    containsExact: function(a,i,m){
    return $.trim(a.innerHTML.toLowerCase()) === m[3].toLowerCase();
    },
    containsExactCase: function(a,i,m){
    return $.trim(a.innerHTML) === m[3];
    },
    containsRegex: function(a,i,m){
     var regreg =  /^\/((?:\\\/|[^\/])+)\/([mig]{0,3})$/,
      reg = regreg.exec(m[3]);
     return RegExp(reg[1], reg[2]).test($.trim(a.innerHTML));
    }
    });
    
    0 讨论(0)
  • 2021-01-15 07:10

    Try this:

    $(xml).find("ACT > TITLE").filter(function() {
        return this.firstChild.nodeValue === selectedAct;
    }).siblings('SCENE').each(function() {...
    
    0 讨论(0)
提交回复
热议问题