theorise
theorise

Reputation: 7445

Escaping quotations for jQuery XML request

Simple question really, I am relatively new to both jQuery and XML.

I just want to pull an email address into a link, but unsure how I am escaping the quotations.

<a href="mailto:'+email+'">Email me</a>

The +email+ is being taken from an XML file with code like this: <email>[email protected]</email>

so I want the HTML to look like:

<a href="mailto:[email protected]">Email me</a>

Upvotes: 0

Views: 253

Answers (1)

reko_t
reko_t

Reputation: 56440

You can use the encodeURIComponent (just a plain JS function, not related to jQuery):

<a href="mailto:'+encodeURIComponent(email)+'">Email me</a>

Upvotes: 1

Related Questions