I've been trying to use Semantic UI in my HTML for an Electron app. I am able to load the elements, but I can't use jQuery for some reason. I've tried both my local jQuery copy:
<script src="node_modules/jquery/dist/jquery.min.js"></script>
and the CDN version:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
but none seem to work. I've tried doing simple things with jQuery but that still isn't working either. Any help would be appreciated. I would prefer to use my local copy.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
<!-- <script src="node_modules/jquery/dist/jquery.min.js"></script> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<div class="ui sidebar inverted vertical menu">
<a class="item">1</a>
</div>
<div class="pusher">
<h1 class="asdf" id="asdf">Hello</h1>
</div>
<script>
document.getElementById("asdf").innerHTML = "new1";
$('#asdf').text("new2");
$('#asdf').html("new2");
</script>
<script src="semantic/dist/semantic.min.js"></script>
</body>
</html>
At your index.html
<head>
<script>
window.$ = window.jQuery = require("jquery");
</script>
....
And createBrowerWindow
with nodeIntegration
at your main.js
.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})