admin管理员组文章数量:1025227
I am facing a tricky problem with my code and hope to get some help on this. Below is a snippet of my code:
<SCRIPT type='text/javascript'>
function list(json) {
// list result
$('#pop-up').click(alert(json.length));
}
// declare map and options
google.maps.event.addListener(map, 'idle', function () {
var query = 'some query';
$.getJSON(query, list);
});
</SCRIPT>
<A href='javascript:void(0)' id='pop-up'>Click Me</A>
As seen, the pop-up is supposed to return the length of json object when the pop-up link is clicked. However, I am getting the pop-up without clicking the link. Anyone knows where the problem lies?
I am facing a tricky problem with my code and hope to get some help on this. Below is a snippet of my code:
<SCRIPT type='text/javascript'>
function list(json) {
// list result
$('#pop-up').click(alert(json.length));
}
// declare map and options
google.maps.event.addListener(map, 'idle', function () {
var query = 'some query';
$.getJSON(query, list);
});
</SCRIPT>
<A href='javascript:void(0)' id='pop-up'>Click Me</A>
As seen, the pop-up is supposed to return the length of json object when the pop-up link is clicked. However, I am getting the pop-up without clicking the link. Anyone knows where the problem lies?
Share Improve this question asked Sep 18, 2011 at 11:49 Question OverflowQuestion Overflow 11.3k20 gold badges81 silver badges113 bronze badges1 Answer
Reset to default 7It's because you're using .click()
rather than .click(function() {})
. Replace the $('#pop-up')
line with:
$('#pop-up').click(function() { alert(json.length) });
and get rid of the curly brace underneath that line.
I am facing a tricky problem with my code and hope to get some help on this. Below is a snippet of my code:
<SCRIPT type='text/javascript'>
function list(json) {
// list result
$('#pop-up').click(alert(json.length));
}
// declare map and options
google.maps.event.addListener(map, 'idle', function () {
var query = 'some query';
$.getJSON(query, list);
});
</SCRIPT>
<A href='javascript:void(0)' id='pop-up'>Click Me</A>
As seen, the pop-up is supposed to return the length of json object when the pop-up link is clicked. However, I am getting the pop-up without clicking the link. Anyone knows where the problem lies?
I am facing a tricky problem with my code and hope to get some help on this. Below is a snippet of my code:
<SCRIPT type='text/javascript'>
function list(json) {
// list result
$('#pop-up').click(alert(json.length));
}
// declare map and options
google.maps.event.addListener(map, 'idle', function () {
var query = 'some query';
$.getJSON(query, list);
});
</SCRIPT>
<A href='javascript:void(0)' id='pop-up'>Click Me</A>
As seen, the pop-up is supposed to return the length of json object when the pop-up link is clicked. However, I am getting the pop-up without clicking the link. Anyone knows where the problem lies?
Share Improve this question asked Sep 18, 2011 at 11:49 Question OverflowQuestion Overflow 11.3k20 gold badges81 silver badges113 bronze badges1 Answer
Reset to default 7It's because you're using .click()
rather than .click(function() {})
. Replace the $('#pop-up')
line with:
$('#pop-up').click(function() { alert(json.length) });
and get rid of the curly brace underneath that line.
本文标签: javascriptjQuery Click Event Triggering without ClickingStack Overflow
版权声明:本文标题:javascript - jQuery Click Event Triggering without Clicking - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745611724a2159039.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论