jquery选择器:如何获取一组元素
我有一组jquery选择器:如何获取一组元素,jquery,css-selectors,Jquery,Css Selectors,我有一组和元素 <strong>ex11<strong/>[<strong>ex12<strong/>](<strong>ex13<strong/>) <span>(TP1)<span/> <strong>ex2<strong/> <span>(TP2)<span/> (<strong>ex3<strong/>) <span
和
元素
<strong>ex11<strong/>[<strong>ex12<strong/>](<strong>ex13<strong/>)
<span>(TP1)<span/>
<strong>ex2<strong/>
<span>(TP2)<span/>
(<strong>ex3<strong/>)
<span>(TP3)<span/>
<strong>ex41<strong/>(<strong>ex42<strong/>)
<span>(TP4)<span/>
...
如何使用jquery选择器和执行
目前我正在尝试:
span = $("strong+span")[0] \\(get's the span element from the first set)
span_text = $(span).text()
strongs = $(span).prevUntil("span") \\(gets all the strongs between current span and prev span)
//Now loop over strongs to get the strings.
但是我想要括号
(
和]
首先,是否有任何包含HTML元素的元素可以使选择更容易,或者可以更改HTML结构使其更具语义?其次,研究jQuery中的方法。第三,请展示您尝试过的内容,以便我们可以帮助您调试它
span = $("strong+span")[0] \\(get's the span element from the first set)
span_text = $(span).text()
strongs = $(span).prevUntil("span") \\(gets all the strongs between current span and prev span)
//Now loop over strongs to get the strings.