I am trying to give the value of an data-bind: text function to the href="mailto:" but can't seem to get it right.
My Code so far:
HTML:
<a href="#" class="mailCloseBranch" data-bind="text: closestBranch().email">someEmailFromDataBind.com
</a>
Replacing Value of href:
$("a.mailCloseBranch[href$='#']").each(function() {
var ref = document.getElementsByClassName('mailCloseBranch')[0].value;
var mailref = 'mailto:' + String(ref);
this.href = this.href.replace("#", mailref);
});
The 'mailto:' string from var mailref gets insertet and the correct email is displayed in the
<a> element
but the value of var ref stays undefined which in turn leads to no link to "mailto".