我想知道如何在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>
亲切的问候,
答案 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>";
要理解的一个例子: -
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;