Sorry in advance as I know how basic this question is but I'm struggling to find the answer to this.
I'm trying to connect two objects together, some text & a url and send them to a class.
The code I have that's working just fine is only using one of the objects at the moment;
$('.myclass').text(obj.mytext);
I'm stuck on how to attach the second object (obj.myurl) to this so it output's the text as a clickable link?
尝试:
$('.myclass').text(obj.mytext).attr('href',obj.myurl);
You shoule
$('.myclass').html('<a href="' + obj.myurl + '">' + obj.mytext + '</a>');
or
$('<a/>', { href : obj.myurl, text: obj.mytext }).appendTo('.myclass')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.