[英]Why this alert box don't get triggered ? Chasing a ghost here?
I'm getting crazy already: 我已经快疯了:
I have exactly this same code on my application: 我的应用程序上有完全相同的代码:
http://jsfiddle.net/MZbLW/144/ http://jsfiddle.net/MZbLW/144/
EXACTLY THE SAME. 一模一样。
However, on my application the SECOND alert box NEVER shows. 但是,在我的应用程序中,从不显示第二个警告框。
Here's the copy paste: 这是复制粘贴:
<script>
if (typeof jQuery != 'undefined') {
alert("jQuery library is loaded!");
}else{
alert("jQuery library is not found!");
} // yes I'm this desperate!
$(document).ready(function() {
// Using on method
$(".trigger").on("click", function()
{
// Using length instead of size. Using === instead of ==
if($('#localized fieldset').length === 1)
{
window.alert("PLEASE SHOW "); //THIS DOESN'T APPEAR;
}
else
{
$('#localized fieldset:last-child').remove();
// Toggle visibility.
$(".trigger").toggle();
}
//return false; //prevent default anchor action;
});
});
</script>
<style>
.linkRemove {
display:none;}
</style>
<div id="localized">
<fieldset>
<label>hello</label>
<input type="text" />
</fieldset>
</div>
<a class="trigger" href="#"> Add Translation ▼</a>
<a class="trigger linkRemove" href="#"> Remove Translation</a>
I'm aware that without accessing the application code itself, it's not easy to debug, but, a simple "What could it be" may help me figuring this out. 我知道,不访问应用程序代码本身,调试起来并不容易,但是,简单的“可能会是什么”可能会帮助我弄清楚这一点。
Please advice. 请指教。
Issue solved. 问题已解决。
It was related with the fact that the Application was running a different Jquery version of that on Jsfiddle. 这与以下事实有关:应用程序在Jsfiddle上运行了与该版本不同的Jquery版本。
The method "on" was not suported, hence, the fact we were getting different outputs with the same code. 不支持“ on”方法,因此,事实是我们使用相同的代码获得了不同的输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.