javascript - Change JS function to jQuery -
how can change code take advantage of jquery?
function download(elm) { var iframe = document.createelement("iframe"); var param = elm.innerhtml; //$get("filedownload").innerhtml; //iframe.src = "generatefile.aspx?filename=386c1a94-fa5a-4cfd-b0ae-40995062f70b&ctype=application/octet-stream&ori=18e73bace0ce42119dbbda2d9fe06402.xls";// + param; iframe.src = "generatefile.aspx?" + param; iframe.style.display = "none"; document.body.appendchild(iframe); }
it this:
function download(elm) { $("<iframe />", { src: "generatefile.aspx?" + elm.innerhtml }) .appendto("body").hide(); }
this jquery 1.4+ $(html, props)
syntax, older versions this:
function download(elm) { $("<iframe />").attr("src","generatefile.aspx?" + elm.innerhtml) .appendto("body").hide(); }
past creation .appendto()
appends element created selector passed in ("body"
), , .hide()
covers display: none;
styling.
Comments
Post a Comment