I have the following code in javascript.
var contents = '<p>this is some text.<span class="Am"></span>This is som text<span class="Am"></span>This is some text<span class="Am"></span></p>';
Now I have to find the number of occurences of span tag inside this string and then use a loop throgh this number. For example
function doStuff(){
var contents = '<p>this is some text.<span class="Am"></span>This is som text<span class="Am"></span>This is some text<span class="Am"></span></p>';
var spans = 'Number of spans in the string'; // this is required to me
for(i=1;i<=spans;i++){
// do some stuff
}
}
Can anyone tell me how it can be done with javascript ?
Thanks in advance.