<div id="AriaAlertReceiver" aria-live="polite"></div>
EmsUtils.showAriaAlert = function(msg) {
var alertDiv = $("#AriaAlertReceiver");
if (alertDiv[0]){
// Set the alert text in a div - it already has aria-live=polite
// This will be actually ignored by IE for now
alertDiv.html(msg);
setTimeout(function () {
// Change the message again after a short time - now IE does detect it
if (zk.ie >= 11) {
alertDiv.html(msg + "!");
}
setTimeout(function () {
// Remove the alert after a short time, so it can be used again later
alertDiv.html("");
}, 1000);
}, 100);
}
}
上面的代码正在用选定的元素对象替换html,但是当我点击重试时它显示的函数没有定义。
答案 0 :(得分:2)
您需要将跨度上的点击绑定到文档,此代码将帮助您。
$("#showloader").replaceWith("<span class='iconexclaim'><img src='images/backupiconexclaim.jpg' /></span><span class='retry-btn' >Retry</span>");
$(document)
.on(
'click',
'.retry-btn',
function() {
alert("I am here") ;
}) ;
答案 1 :(得分:2)
如果将abc()
包裹在头部标签内或身体负荷上,它将起作用:
function abc() {
alert("hi");
$("#showloader").replaceWith("<span class='iconexclaim'><img src='images/backupiconexclaim.jpg' /></span><span class='retry-btn' onclick='abc()'>Retry</span>");
}
$(document).ready(function(){
abc();
});
<强> http://forums.asp.net/t/1975897.aspx?jquery+ajax+calls+to+asp+net+web+methods+authentication+error+ 强>
答案 2 :(得分:0)
在调用.replaceWith
或操纵dom之前,您需要将该功能代码块放在某处(在其上方)。
答案 3 :(得分:0)
请尝试这样:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> </script>
<script>
$(document).ready(function() {
$("#showloader").replaceWith("<span class='iconexclaim'> <img src='images/backupiconexclaim.jpg' /></span><span class='retry-btn' onClick='abc()'>Retry</span>");
});
function abc(){
alert("abc");
}
</script>
</head>
<body>
<div id='showloader'>helloo world</div>
</body>
</html>