auftragsmoewe auftragsmoewe - 1 year ago 99
jQuery Question

jQuery button doesnt work

Im very new to working with jQuery, and I dont have much experience, so please excuse me if Im making stupid mistakes.

$(document).ready(function() {
$("#button").click(function() {
if ($("#button").hasClass("clicked-once")) {
else {


I got this idea from this forum, and I dont even know if these commands are valid, but if they exist, I wouldnt know why it doesnt work.
The html site looks somewhat like this:

<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="scripts/jquery.js"></script>
<body id="list">
<SPAN title="cool hover text"> <a class="list" href="sites/link.html" target="ContentFrame"> link </a> </span>
<button type="button" id="design_button"> Design </button>
<script src="scripts/main.js"></script>

I dont really know what to do to be honest, thanks in advance

Answer Source

In your html, there is no button with id "button". JQuery selector # is for id:s. So In your case, it would work with $('#design_button').

$(document).ready(function() {
$("#design_button").click(function() {
    var btn = $(this);
    if (btn.hasClass("clicked-once")) {
    else {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download