jquery星级评分插件和jquery点击功能
我正在使用 jquery 星级评分插件: http://www.fyneworks.com/jquery /star- rating/
我可能会得到一些像这样的 html 代码:
<form name="api-disable">
<input type="radio" class="star {split:2}" name="api-readonly-test" value="1"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="2"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="3"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="4"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="5"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="6"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="7"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="8"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="9"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="10"/>
<input type="button" value="Submit »" onClick="
$(this).next().html( $(this.form).serialize() || '(nothing submitted)' );
"/>
<span></span>
</form>
这工作正常,但如果我尝试调用我自己的函数,我的函数不会发出警报。例如:
$('.star').click( function () {
alert('test');
});
我也尝试附加一个 id 并使其成为点击功能,但仍然没有成功。如果我从按钮中删除星级类,那么我的功能将起作用。所以这个插件中的一些代码似乎阻止了外部函数?我需要做什么来调用我自己的函数?
I'm using the jquery star rating plugin: http://www.fyneworks.com/jquery/star-rating/
I might get some html code like this:
<form name="api-disable">
<input type="radio" class="star {split:2}" name="api-readonly-test" value="1"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="2"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="3"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="4"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="5"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="6"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="7"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="8"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="9"/>
<input type="radio" class="star {split:2}" name="api-readonly-test" value="10"/>
<input type="button" value="Submit »" onClick="
$(this).next().html( $(this.form).serialize() || '(nothing submitted)' );
"/>
<span></span>
</form>
This works fine, but if I try to call my own function my function doesn't alert. For example:
$('.star').click( function () {
alert('test');
});
I also tried attaching an id and making that the click function, but still no luck. If I remove the star class from the buttons then my function will work. So it seems some of the code in this plugin prevents outer functions? What would I need to do to call my own function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该文档建议您可以添加点击回调,以及当您激活该插件时,还会发生一些其他事件:
The documentation suggests you can add a click callback, as well as some other events, when you activate that plugin: