I am using innerText to add text to my object. Is there an easy way to add a hyperlink to the text? 'trend' also has a attribute called 'link'.

this.node.innerText = trend.get('value');
有帮助吗?

解决方案

You need to add a DOM element using jQuery's wrap():

$(this).wrap('<a href="..." />');

其他提示

Use **WRAP** function

  $(someSelector).wrap(function() {
       var link = $('<a/>');
       link.attr('href', 'somewhere_far_far_away');
       link.text($(this).text());
       return link;
    });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top