Bruse
Bruse

Reputation: 313

Add variable to href link in my JavaScript file

I'm trying to use a variable (or to find another way) to use a variable into my href.

Can anybody help with that?

app.on('changeup:myNewTender', function(data){
    var urrl = "/#manage/"+data._id;
    $.pnotify({
        type: 'success',
        delay: 3000,
        text: '<a href=urrl>Your  tender has been published</a>'
    });
}

Upvotes: 0

Views: 97

Answers (2)

Alexis King
Alexis King

Reputation: 43842

You should use string concatenation using +. You should also surround the URL with quotes of some kind, since good practice states that HTML attributes should be quoted.

'<a href="' + urrl + '">Your  tender has been published</a>'

Upvotes: 1

tymeJV
tymeJV

Reputation: 104775

String concatenation:

'<a href=' + urrl + '>Your  tender has been published</a>'

Upvotes: 4

Related Questions