0

I have to get span tag from in response body where i have many html element. Below is the span element which i have to find:

 <span  title="WorldVentures Fdn" data- scribe="element:name">WorldVentures Fdn</span>      
<span  title="@WVFoundation" data-scribe="element:screen_name" >@WVFoundation</span>

I used this code:

data.body = data.body.replace(/(<span[^c]*class="TweetAuthor-name Identity-name customisable-highlight"[^>]*>)/g, '');

This code is something fine only need to put closing tag for span also so closing tag with text still remains there.

How do i remove this span from complete body?

5
  • If you have HTML in a string and wish to manipulate it then use the DOM manipulation features of the browser, E.g. How to parse HTML from an AJAX request? Commented Nov 4, 2016 at 11:34
  • Alex, I tried this code var getSpan = div.querySelector("span.TweetAuthor-name Identity-name customisable-highlight"); getting null in getSpan variable. Commented Nov 4, 2016 at 12:29
  • This solution is fine for me: data.body = data.body.replace(/(<span[^c]*class="TweetAuthor-name Identity-name customisable-highlight"[^>]*>)/g, ''); but the issue here is i am not closing span tag in this regex so closing span tag with value still showing there. could you make this regex correct? Commented Nov 4, 2016 at 12:41
  • Don't use comments to post your code. Edit your question and put it there. Commented Nov 4, 2016 at 12:52
  • K thanks i am editing my question. Commented Nov 4, 2016 at 12:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.