Reputation: 227
<html>
<head></head>
<body>
<div class="mtb-desc">
some contentsome contentsome contentsome contentsome contentsome contentsome contentsome content.
some contentsome contentsome contentsome entsome contentsome contentsome contentsome contentsome.
NO : 212122Name is Jone</div>
<span class="mtb-price">
<label Class="mtb-ofr"><b class="lb1"></b>WWWW</label></span>
<script>
var eg1 = document.querySelectorAll('.mtb-desc')[0].childNodes[0].split(null)[1].nodeValue;
var eg2 = document.querySelectorAll('.mtb-ofr')[0].childNodes[1].nodeValue = eg1;
alert(eg2);
</script>
</body>
</html>
In above code i want to replace WWWW with text Name is Jone. so how do i access 'Name is Jone' text from that text node ?
Upvotes: 1
Views: 99
Reputation: 4423
To match the ending non-numeric text and insert it where WWWW is, do this:
var content = document.querySelectorAll('.mtb-desc')[0].innerText;
var insertion = content.match(/[^0-9]+$/)[0];
document.querySelectorAll('.mtb-ofr')[0].innerText = insertion;
Upvotes: 1