I want to search the string in anchor tag, When I simply search the "Happy" without space it works fine however when I search it with some space like "Happy " it does not work.
Below is the code sample:
<html>
<body>
<a style="color:#555555" href="Happy coding!!">test</a>
<br/>
<script type="text/javascript">
var hrefTags = document.getElementsByTagName("a");
var bDayId = "";
var stringToSearch = "Happy coding!!";
for(var hrefIndex=0; hrefIndex < hrefTags.length; hrefIndex ++){
bDayId = hrefTags.item(hrefIndex).href.toString();
document.write(bDayId+"<br/>");
document.write( bDayId.indexOf("Happy "));
}
</script>
</body>
</html>