Javascript jQuery旋钮释放功能附加参数
我正在使用jQuery旋钮插件 现在,我有了以下jQuery旋钮初始化Javascript jQuery旋钮释放功能附加参数,javascript,php,jquery,wordpress,jquery-knob,Javascript,Php,Jquery,Wordpress,Jquery Knob,我正在使用jQuery旋钮插件 现在,我有了以下jQuery旋钮初始化 loop <input type="text" value="<?php echo $score; ?>" class="circle-rating" data-entryid="<?php the_ID(); ?>"> endloop $(function() { $(".circle-rating").knob({ 'min':0,
loop
<input type="text" value="<?php echo $score; ?>" class="circle-rating" data-entryid="<?php the_ID(); ?>">
endloop
$(function() {
$(".circle-rating").knob({
'min':0,
'max':10,
'step':1,
'width':40,
'height':40,
'fgColor':"#F59B00",
'inputColor':"#F59B00",
'displayPrevious': true,
'release' : function (v) {
var entry_id = $(this).attr('data-entryid');
jQuery.post("/path/to/file/update_library_score.php", {v : v, entry_id : entry_id}, function(data) {
console.log(entry_id);
jQuery('#notification-general').html(entry_id);
});
}
});
});
循环
在release函数中试试这个
alert(this.$.attr('data-entryid'));
参见演示您可以通过data-*
使用自定义属性来创建。圈出评级
元素,并通过发布函数中的$(this.attr('data-*))访问它。其中*可以是任意字符串uwant@Nouphal.M我已经用你说的(我想)更新了我的问题,但它似乎不起作用。entry\u id输出是什么?。签入控制台或警告该值and@Nouphal.M修复了语法错误,并尝试了console.log(条目id)
正如您在更新的问题代码和控制台中看到的,返回未定义的。是的,看起来像这个。$.attr('data-entryid')
代替$(this.attr('data-entryid')