Adding onClick event dynamically using jQuery

后端 未结 6 1830
梦毁少年i
梦毁少年i 2020-11-30 22:24

Due to a plugin being used, I can\'t add the \"onClick\" attribute to the HTML form inputs like usual. A plugin is handling the forms part in my site and it doesn\'t give an

6条回答
  •  [愿得一人]
    2020-11-30 22:50

    try this approach if you know your object client name ( it is not important that it is Button or TextBox )

    $('#ButtonName').removeAttr('onclick');
    $('#ButtonName').attr('onClick', 'FunctionName(this);');
    

    try this ones if you want add onClick event to a server object with JQuery

    $('#' + '<%= ButtonName.ClientID %>').removeAttr('onclick');
    $('#' + '<%= ButtonName.ClientID %>').attr('onClick', 'FunctionName(this);');
    

提交回复
热议问题