Home > OS >  How to find the corresponding div closing tag?
How to find the corresponding div closing tag?

Time:08-13

I have a html code like following

<div >
 <h1>ddd</h1>
 <p>dadfsaf</p>
 <div id="name">
  <div >psd</div>
  <div>www</div>
 </div>
 <div>ppp</div>
</div>

I would like to get the content inside a div that starts with <div id="name"> and ends with its corresponding closing tag. Here the content is

<div >psd</div>
<div>www</div>

I tried <div id="name">.*</div>, but it doesn't work. Please help, thank you.

Append, I wrote this code in node.js.

CodePudding user response:

var name = $("#name").html()
console.log(name)

CodePudding user response:

"name" is keyword,so don't work,rename it,try again

  • Related