Frank Morrison
Frank Morrison

Reputation: 51

How to pass the achor text innerHtml in javascript

I have an anchor text link that contains information that I need to parse:

<a href="javascript:parselink(this)">
    <div class="calendar">
        <div class='day'>8</div>
        <div class="number">75</div>
    </div>
</a>

  <script>
    function parselink(link){
        alert(link.innerHtml);
    }
  </script>

However, I am not able to get the anchor text's innerHhtml.

Upvotes: 1

Views: 41

Answers (1)

epascarello
epascarello

Reputation: 207511

You have a typo

innerHtml !== innerHTML

And use onclick, not href to trigger the event

    function parselink(link){ 
        alert(link.innerHTML);
    }
<a href="#" onclick="parselink(this); return false;">
    <div class="calendar">
        <div class='day'>8</div>
        <div class="number">75</div>
    </div>
</a>

Upvotes: 2

Related Questions