In my code I have this type of text:
<h1>{{text}}</h1>
<p>{{other text}}</p>
How to get with with jQuery, those texts ?
-
My first idea was:
$(regex).each(function( index ) {
alert(index); // must return {{text}}
}
In my code I have this type of text:
<h1>{{text}}</h1>
<p>{{other text}}</p>
How to get with with jQuery, those texts ?
-
My first idea was:
$(regex).each(function( index ) {
alert(index); // must return {{text}}
}
You're using each
incorrectly:
$(regex).each(function() {
alert($(this).html()); // must return {{text}}
});
Note that in the demo I used body *
as the selector. jQuery doesn't take regex selectors, so you will need to write a proper selector.
Also note that your original code was missing );
at the end; I have added it.
aaaaaa
`, it will match it whereas this text is not between `{{` and `}}`. – Dec 15 '14 at 19:36