在变量javascript上放置一个href链接

时间:2017-03-08 11:32:19

标签: javascript jquery html

我想知道如何在JavaScript中的变量之外放置html href链接。这是我现在的JavaScript函数

var Investor1 = member(380,0,'UBO',GraphData['Investor 1'],'male.png', '#C5CACA', '#000000');
var Investor2 = member(620,0,'UPC',GraphData['Investor 2'],'male.png', '#C5CACA', '#000000');

我想有这样的事情:

<a href="">var Investor1 = member(380,0,'UBO',GraphData['Investor 1'],'male.png', '#C5CACA', '#000000'); </a>
<a href=""> var Investor2 = member(620,0,'UPC',GraphData['Investor 2'],'male.png', '#C5CACA', '#000000'); </a>

亲切的问候,

1 个答案:

答案 0 :(得分:0)

你可以这样做: -

var Investor1 = member(380,0,'UBO',GraphData['Investor 1'],'male.png', '#C5CACA', '#000000'); 

var Investor2 = member(620,0,'UPC',GraphData['Investor 2'],'male.png', '#C5CACA', '#000000'); 

然后: -

var link1 = "<a href=''>"+ Investor1 +"</a>"; 

var link2 = "<a href=''>"+ Investor2 +"</a>";

要理解的一个例子: -

&#13;
&#13;
var Investor1 = 'First Link to Click!'; 
var Investor2 = 'Second Link to Click!';

var link1 = "<a href=''>"+ Investor1 +"</a>"; 
var link2 = "<a href=''>"+ Investor2 +"</a>";

$('#myDiv').html(link1+"<br/>"+link2);
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id ="myDiv"></div>
&#13;
&#13;
&#13;