Stijn De Schutter
Stijn De Schutter

Reputation: 257

Jquery .click() doesn't work in chrome

I have this strange problem, I never had before and it only occurs in Google Chrome browser. I have made a function to create a writebutton (that writes a value to my PLC true ajax). This is how it looks:

    function makeWriteButton(id, address, value, startRefresher){

            $("#" + id).click( function() {
                writeData(address, value, startRefresher);
            });
    }

So you pass the id of your input button to that function and the function adds a click event handler, this function works perfect in IE, Firefox, Safari, Opera, but not in Chrome.

Does anyone have any suggestions or reasons why this doesn't work? and by the way this function used to work before on chrome but I don't know what I did so it's doesn't work anymore in chrome, really weird.

Upvotes: 0

Views: 1309

Answers (1)

Xotic750
Xotic750

Reputation: 23472

I don't think your problem is in that section of code, this worked for me on Chromium

<button id="but1">Button1</button>
<button id="but2">Button2</button>
<button id="but3">Button3</button>
<button id="but4">Button4</button>
<button id="but5">Button5</button>

function makeWriteButton(id, address, value, startRefresher) {
    $("#" + id).click(function () {
        alert(address + " " + value + " " + startRefresher);
    });
}

makeWriteButton("but3", 5, 6, 7);

on jsfiddle

Upvotes: 1

Related Questions