-6

If i have

<p>someword here</p>
<span>another thing here</span>new line

this is as a string
How do i get the content of span?

I want the result to be

another thing here
new line

update :

<script>
var string = "<span>this is span</span>new line";
var anchors = $('<div/>').append(string).find('span').text();
console.log(anchors);
</script>

output:-

this is span

and want to new line

웃웃웃웃웃
  • 362
  • 3
  • 17
  • 32

1 Answers1

0

you can assign a id or class to span and using jquery

<span class="myclass" id="myid">another thing here</span>

jQuery('#myid').html();

or

jQuery('.myclass').html();

but the class method will give you all the elements having class "myclass"

Mubbashar
  • 613
  • 6
  • 15