如何在Javascript中添加html标签:var quotes = new Array(“tags html here”)

时间:2014-10-12 10:09:42

标签: javascript jquery arrays quotes

您好我尝试在"数组"中添加html标签我的代码,你能帮助我吗?

$(document).ready(function() {
    var quotes = new Array("exemple exemple","exemple...");
    var randno = Math.floor(Math.random()*(quotes.length));
    $('.quote').append(quotes[randno]);
    console.log(randno);
}

1 个答案:

答案 0 :(得分:0)

简单地将您想要的标记写入数组(并使用'作为标记中的引号)

....
var quotes = new Array("<li>bla</li>","<a href='http://www.google.com'>link</a>");

....
var quotes = new Array();
quotes.push("<li>asdf</li>");