For example our url: example.com
and source code is:
<html>
<head>
<body>
Hello My Name is: Jane
</body>
</head>
</html>
My question is: How we can get only "Jane" part using javascript?
For example our url: example.com and source code is:
My question is: How we can get only "Jane" part using javascript? |
||||
While looking at this page, pop up your browser's Javascript console and type:
and you may see
You could assign the array to a variable and extract the second element. One one line:
However, note that there can be horrific consequences of extracting things out of HTML with a regular expression and so it is considered a bad practice. |
|||||
|
document.body.textContent
but it's far better to give the parent element anid
and look that up usingdocument.getElementById(..)
– Mr Lister Jun 15 at 11:18