var main_div = $('div[class^="select"]');
var download_button = document.createElement('a');
download_button.setAttribute("id", "download");
download_button.style.color = "blue";
download_button.href = "#";
download_button.innerHTML = "Download";
main_div.append(download_button);
Nothing Happens,没有附加新元素来选择这个错误吗?
答案 0 :(得分:1)
答案 1 :(得分:0)
你可以在jQuery中这样做:
var main_div = $('div[class^="select"]');
$("<a/>")
.attr("id","download")
.css("color","blue")
.attr("href","#")
.html("Download")
.appendTo(main_div);
答案 2 :(得分:0)
不要像你那样混合使用jQuery和JS ......
var main_div = $('div.select');
var download_button = $('<a id="download" style="color:blue;" href="#">Download</a>');
main_div.append(download_button);