Hi i'm very new to electron
please bear with me.
i have a situation like this:
i will get filename from
li
once the
filename
got i want to write it with below codevar fs = require('fs'); fs.writeFile('gotfromjsvariable', 'Hello content!', function (err)
{ if (err) throw err; console.log('Saved!'); });
suppose gotfromjsvariable
is coming from below code
question is, How do i pass it to electron main.js or same file node.js
$(document).on('click','#files li',function(){
var gotfromjsvariable = $(this).data('filename');
// gotfromjsvariable has to be sent a filename to nodejs or electron
/*
var fs = require('fs');
fs.writeFile('gotfromjsvariable', 'Hello content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
*/
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="files">
<li data-filename="abc.json">abc.json</li>
<li data-filename="pqr.json">pqr.json</li>
</ul>