[QUES] How to put a button in this code

hey, could someone tell me how to put a a button next to his html code that has a JS function when you click it?
Preferably one of the awesome font css icons : http://fortawesome.github.io/Font-Awesome/icons/

code on pastebin: http://pastebin.com/hWpP71Bm

github : https://github.com/Rex0099/GDT-OnlinePlay

Something like this?

<div class="icon-bell" style="width:20; height:20" onclick="JSFUNCTION()"></div>

EDIT:

Something to note is that the Font awesome library that is packed with the game so some of the naming scheme is a little different. I suggest you take a look at the font awesome css in the css folder.

1 Like

ok, thanks, and if i had a function a for example in the jsfuntion i would put function(A)

Well actually the best way to do this considering I don’t know your code structure etc would be to just assign a onlick function via js. So included in your initial code:

$( "#myIconButton").on( "click", function() {
//my function.
});

So your button html would be something like this:

<div id="myIconButton" class="icon-bell" style="width:20; height:20"></div>
2 Likes

my mod code got a error when i went on… didn’t change a thing, it says unexpected token ILLEGAL

Well that code is fine on it’s own so you would need to either parse your code and try and fix the error or post your code.

http://www.javascriptlint.com/online_lint.php

tried the online lint
said all was fine

Check all your code. That code seems fine.
Also open up the console and check the line number and file of the error.

The console button will appear in the top left if you open up the package.json file in the root GDT directory.
Then change the “toolbar” field to “true”, save and restart the game.

EDIT: Your HTML has an error in it though:

<div class="windowTitle smallerWindowTitle">Multiplayer</div><div><input type="text" name="OnlinePlayIP" id="JoinServer-onlineplay" class="css-textbox"/><label for="JoinServer-onlineplay" class="css-label"></label><br /><small>will replace text</small><div id="ConnectButton" class="icon-bell" style="width:20; height:20"></div></div>

Also this should be your html as your are missing a closing div. Although this should cause an immediately noticeable issue depending how it is parsed into game. But either way make sure you are checking your html too.

ok, thanks. I fee stupid now XD… probably cause i suck at it anyway

Wait… you are also making a multiplayer mod? :wink:

@LineLiar yea, not going to announce till i have a working product. its going to focus more on plugins, a bit like minecraft has bukkit and vanilla