Yas Seen
Yas Seen

Reputation: 29

Change a class to add it to a link

I have this little code here:

<script>
    $(function() {
        $('.insert_usrdata_name').text($('.client-profile td:contains("Name:")').next().text());
        $('.insert_usrdata_email').text($('.client-profile td:contains("E-mail:")').next().text());
        $('.insert_usrdata_regdate').text($('.client-profile td:contains("Registration:")').next().text());
        $('.insert_usrdata_logindate').text($('.client-profile td:contains("Last Login Time:")').next().text());
        $('.insert_usrdata_loginIP').text($('.client-profile td:contains("Last Login From:")').next().text());
        $('.insert_webdata_domain').text($('.account-information td:contains("Domain:")').next().text());
        $('.insert_webdata_status').text($('.account-information td:contains("Status:")').next().text());
        $('.insert_diskusg_percentage').text($('.account-information td:contains("Disk Usage:")').next().text());
        $('.insert_diskusg_numbers').text($('.account-information td:contains("Disk Usage:")').next().text());
        $('.insert_bandwidthusg_numbers').text($('.account-information td:contains("Bandwidth:")').next().text());
        $('.insert_srvdata_url').text($('.account-information td:contains("Server Name:")').next().text());
        $('.insert_srvdata_srvload').text($('.account-information td:contains("Web Server Load:")').next().text());
        $('.insert_srvdata_dbload').text($('.account-information td:contains("MySQL Server Load:")').next().text());
        $('.progress.xs .diskusgbar').css('width', $('#diskUsageProgressBar .green-bar').css('width'));
        $('.progress.xs .bandusgbar').css('width', $('#BandwidthProgressBar .green-bar').css('width'));
    });
</script>

When I use <span class='insert_webdata_domain'>N/A</span> it load website URL if URL is available... But I want to make it work with a link for example <a href="insert_webdata_domain"> Load site </a>. How to achieve this?

Upvotes: 1

Views: 52

Answers (1)

Sachin
Sachin

Reputation: 2148

Replace your line :

$('.insert_webdata_domain').text($('.account-information td:contains("Domain:")').next().text());

to :

$('.insert_webdata_domain').text('<a href="' + $('.account-information td:contains("Domain:")').next().text() + '">' + $('.account-information td:contains("Domain:")').next().text() + ' </a>');

Update

as per your comment if you want to keep span and also want to add link then:

$('.insert_webdata_domain')
.text($('.account-information td:contains("Domain:")').next().text())
.append('<a href="' + $('.account-information td:contains("Domain:")').next().text() + '">' + $('.account-information td:contains("Domain:")').next().text() + ' </a>');

Upvotes: 1

Related Questions