[jQuery] Simple Syntax Help please!
I'm trying to set up a 'mailto' href within an existing tag. The tag
is set up to look like this before the jQuery
<a href="#" mLink="partners" mSubject="Partnership Enquiry"
mText="Click to enquire"></a>
Our site is aliased to several domain names. Where the URL host is
2gc.co.uk, the final tag I'm hoping for looks like this:
<a href="mailto:partners@2gc.co.uk?subject=Partnership Enquiry">Click
to enquire</a>
The code I have to do this right now looks like this:
jQuery('a[mLink="partners"]').attr("href","mailto:partnerships@"+window.location.host
+"?subject=Partnership Enquiry").text("Click to enquire");
Clearly what I'd like to do is adjust this code to have the word after
'mailto' be taken from the attribute mLink, and the text after
'subject=' to be taken from the attribute mSubject. But try as I
might, I can't work out a way to get jQuery to do this. My initial
thought was to embed an attribute request within the main query - kind
of like this
jQuery('a[mLink="partners"]').attr("href","mailto:"+jQuery(this).attr('mLink')
+"@"+window.location.host+"?subject=Partnership Enquiry").text("Click
to enquire")
But this returns 'undefined@..." not "partners@..." - similarly with
attempts to insert the subject text.
I am sure this is easy if you know how. I'd be very grateful for any
assistance from wiser minds on how to achieve what I'm attempting.
Thanks in advance for any help offered.