I am using jQuery attr()
and I would like to add there HTML tag <br />
, but on page it doesn't compile it and shows that tag as string. So is there any way to use HTML tag inside of attr()
or what should I use instead of it?
Code is below, thanks for all advices!
if (Object.keys(result.lastComment).length > 0) {
$(self).attr('data-original-title',
result.commentCreatorName+ '<br />' +
result.date + '<br />' +
result.lastComment.comment
);
}
` into the attribute `data-original-title`. What, if anything, that will mean will depend entirely on what you use `data-original-title` for, since it's not used for anything by the browser and will just store the text you put in it. If you use it as markup, `
` will be a line break. If not, it won't, it'll just be the characters `<`, `b`, `r`, ` `, `/`, and `>`. – T.J. Crowder Mar 21 '17 at 11:35
`, just a line break: http://stackoverflow.com/questions/37476334/how-to-add-line-break-in-title-attribute-using-jquery/42926132#42926132 But I have no idea whether that's what you're doing. – T.J. Crowder Mar 21 '17 at 11:43
` is – hstur Mar 21 '17 at 11:48
` will work. but i repeat. it all depends on what you want to do with that attribute – Mihai T Mar 21 '17 at 11:52