-3

I need to add a value to href by adding a var. But it looks like i've got a syntax error somewhere. And can't figure out what's wrong.

var abra = "whatever";
$("a.confsbmt").attr('href','http://example.com/example2"+abra+"');
Vici A
  • 83
  • 1
  • 6

1 Answers1

1

The string begins in single quotes so should end in single quotes to concatenate anything else on, if you want to use double quotes start with double quotes.

$("a.confsbmt").attr('href','http://example.com/example2'+abra);
depperm
  • 10,606
  • 4
  • 43
  • 67