简体   繁体   中英

Unable to find click event

Here is my JQuery Code:

$(function () {
$('[id*=clickbtn]').click(function () {
    var url = "WindowPages/EditorControl.aspx?controlName=" + this.name;
            oWnd.setUrl(url);
            oWnd.show();

        });

});

Now the problem is, i have 4 to 5 buttons whose id contains 'clickbtn' when i click the any one of them for first time it works well. But it does not works for second click, any help why is this happening?

[EDIT]:

I tried putting the JQuery on page and it worked.. But wnt to know why it does not work on when i put the same on .JS file?

Yes, the result of your event handlers depends very much on the content of your event handlers. If you'd like to share with us the rest of the code we might be able to help. For now the answer is: working as intended

jsFiddle

If your clicks only work on the first try, then I can assure you that it is only the missing code which is to blame. Provide the contents of oWnd.setUrl and oWnd.show and we might be able to help.

Your wildcard selector is wrong. It should be

$("[id$=clickbtn]")

Try this:

$('input[ID*="Button"]')




First set to all buttons you want to do this action then 为要执行此操作的所有按钮,然后

$(function() {
        $('.btn').click(function() {
        var url = "WindowPages/EditorControl.aspx?controlName=" + this.name;
        oWnd.setUrl(url);
        oWnd.show();
        });
    }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM