javascript - match is not a function - Error -
i want test object pattern , output if consolel gives me error saying match not function whereas w3school says javascript function
var templateregex = '/\${([\s\s]*?)\}/g'; var gettextnodesin = function(el) { return $(el).find("*").addback().contents().filter(function() { return this.nodetype == 3 ; }); }; var textnodes = gettextnodesin('#'+currentid); console.log(textnodes.length); for(var i=0; i<textnodes.length; i++) { console.log(textnodes[i]); if(textnodes[i].match(templateregex)) { console.log(textnodes[i]); } } help please?
it looks you're trying match regexp against node; match string method, not htmlelement method.
note jquery's contents() method returns text nodes, not strings. want use text() or html() instead (just checking jquery's api ref @ glance, i'm not jquery expert).
Comments
Post a Comment