Reputation: 1300
I'm creating anchor tag as:
var link = $('<a/>').text("Forget password").attr('href', '/Account/ForgetPassword');
and using it in jquery as:
$error = "Incorrect password." + link + " ?";
and using it in html as: (I'm using knockout)
<div data-bind="text:error"></div>
But the output is:
Incorrect password.[object Object] ?
How can I get the output as a link?
Update: I have used this:
$error = "Incorrect password." + link[0].outerHTML + " ?";
Now the output is:
Incorrect password.<a href="/Account/ForgetPassword">Forget password</a> ?
How to render this as html?
Upvotes: 3
Views: 1024
Reputation: 67207
You have to use its outerHTML
property of Jquery object's underneath node object,
$error = "Incorrect password." + link[0].outerHTML + " ?";
You are simply concatenating the object. So its primitive value is getting concatenated.
Upvotes: 3