gpt4 book ai didi

Internet Explorer 8 中的 JQuery 委托(delegate)不起作用

转载 作者:行者123 更新时间:2023-12-01 08:19:31 27 4
gpt4 key购买 nike

这是代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TITLE</title>

<link type="text/css" href="jsutil/menubar/menu.css" rel="stylesheet"/>
<link type="text/css" media="screen" href="jsutil/tablesorter/css/style.css" rel="stylesheet"/>

<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="jsutil/menubar/menu.js"></script>
<script type="text/javascript" src="jsutil/tablesorter/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="jsutil/tablesorter/js/jquery.tablesorter.pager.js"></script>

<script type="text/javascript">
$(document).ready(function(){

$("#tabe").tablesorter();
$("#tabe").width(600);

$("#tabe").delegate("td", "click", function()
{
var idCampanha = $(this).parent().find("td:first").html();
//Seleciona campanha
alert("clicked in: "+idCampanha);
event.preventDefault();
});


$("#buscacamp").delegate("#bbcamp", "click", function()
{
alert("doing post");
var jqxhr = $.post("php/slistar_campanhas.php",
{nome : $("#bcamp").val() },
function(data)
{
$("#tabe > tbody").empty();
for(var i=0;i<data.length;i++)
{
var obj = data[i];
$("#tabe > tbody:last").append('<tr><td>'+obj.idcampanha+'</td><td>'+obj.nome+'</td></tr>');
}
event.preventDefault();
},
"json"
);
alert("post done");
jqxhr.error(function(){ alert("Erro") });
event.preventDefault();
});


});
</script>
</head>
<body bgcolor="#3B3131">

<div id="menu">
...JUST A WORKING MENU HERE
</div>




<div id="corpo" align="center">
<h1 align="center" style="color:#F8F8F8">Selecionar Campanha</h1>
<form id="buscacamp">
<label style="color:#F8F8F8" for="bcamp">Nome da campanha</label>
<input align="middle" size="35" type="text" name="bcamp" id="bcamp"/>
<br/>
<input type="submit" id="bbcamp" value="OK"/>
</form>
<table id="tabe" class="tablesorter" cellspacing="1">
<thead>
<tr>
<th>Código da Campanha</th>
<th>Nome da Campanha</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Código da Campanha</th>
<th>Nome da Campanha</th>
</tr>
</tfoot>
<tbody>

</tbody>
</table>
<h1 id="titulo" class="cor" style="color:#F8F8F8">Nova Solicitação</h1>
<form id="novasol">
<label for="campanha" style="color:#F8F8F8">Campanha</label>
<input size="20" type="text" name="campanha" id="campanha" readonly/>
<br/><br/>
<label for="titulo" style="color:#F8F8F8">Título</label>
<input size="35" type="text" name="titulo" id="titulo"/>
<br/><br/>
<label for="descricao" style="color:#F8F8F8">Descrição</label>
<textarea rows="17" cols="55" id="descricao"></textarea>
<br/>
<label for="naudios" style="color:#F8F8F8">Número de áudios</label>
<input size="10" type="text" name="naudios" id="naudios"/>
<input type="submit" id="enviar" value="Enviar"/>
</form>
</div>


</body>
</html>

点击 #bbcamp 时的 Chrome 输出:1-提醒做帖子

2-提醒帖子完成

3-向表格添加行,当我单击它们时,它会显示另一个警报

单击 #bbcamp 时的 IE 8 输出:1-提醒做帖子

2-向表中添加行

3-提醒帖子完成

4-删除行并留下一个空表

我尝试使用点击事件,但它也不起作用......我正在使用 jquery 1.7 分钟

有什么想法吗?

最佳答案

IE 是 JScript,不是 JavaScript。

if(event.preventDefault){
event.preventDefault();
}
else{
event.returnValue = false;
}

关于Internet Explorer 8 中的 JQuery 委托(delegate)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8172069/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com