$ sign in jquery to javascript -
i looking way write file in javascript.i found excatly looking here
but problem uses jquery.i suppose task pure javascript.
my question how convert $ sign pure javascript without including jquery script in code.
in short how convert code pure javascript if possible.
function createdownloadlink(anchorselector, str, filename){ if(window.navigator.mssaveoropenblob) { var filedata = [str]; blobobject = new blob(filedata); $(anchorselector).click(function(){ window.navigator.mssaveoropenblob(blobobject, filename); }); } else { var url = "data:text/plain;charset=utf-8," + encodeuricomponent(str); $(anchorselector).attr("download", filename); //when try document,getelementbyid not work. $(anchorselector).attr("href", url); } } $(function () { var str = "kgopelo name in place"; createdownloadlink("#export",str,"file.txt"); });
thanks in advanced.
you need replace jquery functions plain javascript.
- $(anchorselector) -> may replaced getelementbyid or getelementbyclassname
- .click -> how catch click event plain javascript?
- attr -> i want use javascript insert attribute element
- $(function(){ -> run function when page loaded
Comments
Post a Comment