Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用javascript编写的html代码(带有onclick())不起作用_Javascript_Html - Fatal编程技术网

用javascript编写的html代码(带有onclick())不起作用

用javascript编写的html代码(带有onclick())不起作用,javascript,html,Javascript,Html,下面的代码在单独的java脚本文件中动态创建了表,每一行都使用onclick()函数动态创建了按钮,并在单击链接时通过调用某个函数动态创建了链接,但两者都不起作用,这意味着“onclick”不起作用。 当我点击“ClearLogin”按钮时,我想调用另一个函数,这个按钮在JS文件中是writen if(reclist[8] == 'F') { //alert(1); string[j] += "<td><input type='button' disabled=

下面的代码在单独的java脚本文件中动态创建了表,每一行都使用onclick()函数动态创建了按钮,并在单击链接时通过调用某个函数动态创建了链接,但两者都不起作用,这意味着“onclick”不起作用。 当我点击“ClearLogin”按钮时,我想调用另一个函数,这个按钮在JS文件中是writen

if(reclist[8] == 'F')
{
    //alert(1);
    string[j] += "<td><input type='button' disabled='true'name='but_clrlgn_"+reclist[2]+"' value='Clear Login' id='but_clr_"+reclist[2]+"' onClick=\"ClrLogin(this.name)\"></input></td>";
}
else
{
    alert(reclist[8]+" "+reclist[2]);
    string[j] += "<td><input type='button' disabled='true' name='but_clrlgn_"+reclist[2]+"' value='Clear Login' id='but_clr_"+reclist[2]+"'  onClick=\"ClrLogin(this.name)\"></input></td>"; 
    string[j] += '<td><input type="button" value="Click" id="click"/> </td>';
    string[j] += "<td><a href='javascript:aaa()' id='location' >GPS Location</a></td>";
if(重新列出[8]=“F”)
{
//警报(1);
字符串[j]+=“”;
}
其他的
{
警报(重新登录[8]+“”+重新登录[2]);
字符串[j]+=“”;
字符串[j]+='';
字符串[j]+=“”;

首先,像这样更改html

"<td><input type='button' name='but_clrlgn_"+reclist[2]+"' value='Clear Login' id='but_clr_"+reclist[2]+"' class=\"your_button_class\"></input></td>";

如果您想调用其他函数,我的建议是使用类似于以下内容的方法删除onclick。removeAttr(“onclick”);然后使用以下方法执行任何操作:

$(document).ready(function(){
    $('#yourButton').on('click', function(){
        // your code
    });
});

在Clear Login按钮的两个td标记中,我删除了disabled='true'。它是由mistakeNo编写的,但仍然不起作用。……它给出了“属性'ClrLogin'的值为null或未定义,不是函数对象”在IE 9上,您需要从HTML中删除调用。我从HTML中删除了调用,并尝试使用类,但仍然无法使用外部JS:var var string=“”;包含document.ready:$(document).ready(function(){//alert(22);$(document).on(“单击”,“.logclr”,function(){alert('Call success');});});以及如何在html页面的var string外接程序中生成html?没有仍然不起作用,我在IE 9上尝试了这一点,它也没有显示任何错误
$(document).ready(function(){
    $('#yourButton').on('click', function(){
        // your code
    });
});