How Will I Get The Span Class Id Under Which The Text Belongs?
HTML (contenteditable div)
int main(){
Solution 1:
I believe this answers your first and second questions.
It gives you the spans inside the "openParen" and "closeParen" of the "bm2" class, and stores the text inside an array. (This only captures the brackets, because only the brackets are inside the spans.)
var open = $('span[class="openParen bm2"]')
var spans = open.nextUntil('span[class="closeParen bm2"]')
var inside = []
$.each(spans, function(i, span){
inside.push($(span).html())
})
alert(inside.join('-'))
Example here: jsFiddle
EDIT
Not sure how you'll do "between the span tags", I'd start by getting the html of the parent div element, and passing the spans using regex:
var allcontent = $('span[class="openParen bm2"]').parent().html()
var betweenSpan = allcontent.split(/<span class="openParen bm2">[^<]*<\/span>|<span class="closeParen bm2">[^<]*<\/span>/)[1]
var valuesArray = betweenSpan.split(/<[^>]*>/)
Gives you the js array:
[" ", "(", "x>1", ")", " && ", "(", "x<10", ")", " "]
Example here: jsFiddle
Definitely not pretty.
A better solution would be to reconsider the structure of your html tags (i.e. put the values you want to capture inside some tags!)
Anyway, that's enough, I'll leave it up to you.
Post a Comment for "How Will I Get The Span Class Id Under Which The Text Belongs?"