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 , no new element is appended to select what is wrong with this?
You can do this in jQuery like this:
var main_div = $('div[class^="select"]');
$("<a/>")
.attr("id","download")
.css("color","blue")
.attr("href","#")
.html("Download")
.appendTo(main_div);
Do not mix jQuery and JS like you did...
var main_div = $('div.select');
var download_button = $('<a id="download" style="color:blue;" href="#">Download</a>');
main_div.append(download_button);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.