0

How to use <%= item %> in jquery in EJS?

I can use it like this in <html> tags but I wonder if I can use it in <script> tags.

<strong> <%= userx.email %></strong> 

What I want is :

var email = userx.email; 

1 Answer 1

1

Try this:

<script type="text/javascript"> var email = ""; email = "<%=userx.email%>"; </script> 

That's it.

Sign up to request clarification or add additional context in comments.

3 Comments

It's not printing anything when I debug.
The syntax is right. Please make sure your attribute userx.email is returning a value or not.
It's returning and I can see it in HTML tags. The problem is <script type="text/javascript"> is not working in EJS, I guess. Because I can't even log anything in it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.