http://sorgalla.com - jCarousel / jQuery - 回调未在单击锚点上绑定时触发
不得不说,我对于 Javascript 来说还是个新手,但我已经准备好尝试一下了。我似乎无法让以下点击回调工作。它不会触发,并且 Javascript 控制台上没有任何消息。
谁能看出我所做的事情有什么明显错误或不正确的地方吗? 这是基于 http://sorgalla.com - jQuery 之上的 jCarousel。它基于一个简单的示例。不起作用的代码是:
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript" src="jquery.jcarousel.js"></script>
<link rel="stylesheet" type="text/css" href="skin.css" />
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
scroll:1, wrap: 'circular'
});
console.log('ready');
});
jQuery('#mycarousel a').bind('click', function() {
console.log('click');
});
</script>
</head>
<body>
<div id="wrap">
<ul id="mycarousel" class="jcarousel-skin-tango">
<li><a id="test" href="#">Click</a></li>
...
...
</ul>
</div>
任何指针将不胜感激。 谢谢你,马尔科姆
I am a bit of a novice to Javascript I have to have to say - however I am prepared to give things a go. I can't seem to get the following click callback to work . It does not fire and there is no message on the Javascript console.
Can anyone see anything glaringly wrong or incorrect in what I have done .
This is based on http://sorgalla.com - jCarousel on top of jQuery. It is based on a simple example. The code which does not work is :
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript" src="jquery.jcarousel.js"></script>
<link rel="stylesheet" type="text/css" href="skin.css" />
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
scroll:1, wrap: 'circular'
});
console.log('ready');
});
jQuery('#mycarousel a').bind('click', function() {
console.log('click');
});
</script>
</head>
<body>
<div id="wrap">
<ul id="mycarousel" class="jcarousel-skin-tango">
<li><a id="test" href="#">Click</a></li>
...
...
</ul>
</div>
Any pointers would be most appreciated.
thank you , Malcolm
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 jQuery 中嵌入对 console.log() 的调用以查看发生了什么,以下解决了问题:
单击事件现在可以工作。
Embedding calls to : console.log() in jQuery to see what is going on and the following resolves the issue :
click event now works.