Obtener la primera oración HTML
Frecuentes
Visto 569 veces
-3
How get first sentence from html with image assuming image will be between p tags. http://jsfiddle.net/TvyS8/
I need image and first sentence.
I'm thinking about regular expression for image and indexOf for finding symbols of sentence ending. Need more opinions, or example how to do it better
I'm getting information via JSON from Tumblr.
1 Respuestas
2
EDIT:UPDATED FIDDLE
FIDDLE UPDATED
Violín actualizado http://jsfiddle.net/XAtcS/1/
var element={};
$('p').each(function(){
if($(this).children().eq(0).prop('tagName')=='IMG' && $(this).next().children().eq(0).prop('tagName')!='IMG')
{
element.first=$(this).html()+$(this).next().html();
}
})
document.write(element.first)
Ii will take first p text which does not contain img tag
Respondido el 02 de Septiembre de 12 a las 10:09
I need image and first sentence. - mrancys
Doesn't work... The result should be Image and sentence above image "OPS1 continues to improve on its biggest strength: cloud control made easy." - mrancys
you want image after sentence "OPS1"?? - Ashirvad
I see paragraph, but i want only this sentence and image. "OPS1 continues to improve on its biggest strength: cloud control made easy." - mrancys
Thanks, found my on the track. Thanks again man! And updated fiddle :) jsfiddle.net/XAtcS/2 - mrancys
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas javascript jquery html regex or haz tu propia pregunta.
So, in your example, you want
OPS1 continues to improve on its biggest strength: cloud control made easy.
¿como resultado? - João SilvaNot exactly, yes i want this sentence and image above this sentence. - mrancys