jquery:如何传递变量? 100
jQuery(document).ready(function($){$(document).delegate(".sf-praise-listli","hover",f...
jQuery(document).ready(function($){
$(document).delegate(".sf-praise-list li","hover",function(event) {
$(this).toggleClass("sf-praise-item-hover");
});
$(document).delegate(".sf-praise-list li","click",function(event) {
var read=$(this).attr("data-read");
var postid=$(this).attr("data-postid");
var value=$(this).attr("data-value");
var numid = "num"+postid;
if(read=="1"){
alert("你已经投过一次了,还想投么( ̄口 ̄)!!!");
return;
}else{
$.ajax({
type:'post',
async:true,
url:bloghost + "zb_users/plugin/sf_praise/save.php",
data:{
sf_praise_value:value,
postid:postid
},
timeout:30000,
dataType:'html',
complete:function(){
},
success:function(data){
if(data=="ok"){
var ob=$(".sf-praise-list li[data-value='"+value+"']").find("span[type='"+numid+"']");
var sint=parseInt(ob.html(),10);
sint++;
ob.html(sint);
$.tipsBox({
obj: $(".sf-praise-list li[data-value='"+value+"']"),
str: "+1"
});
}else{
alert("你已经投过一次了,还想投么( ̄口 ̄)!!!");
}
}
});
}
});
$.extend({
tipsBox: function(options) {
options = $.extend({
obj: null, //jq对象,要在那个html标签上显示
str: "+1", //字符串,要显示的内容;也可以传一段html,如: "<b style='font-family:Microsoft YaHei;'>+1</b>"
startSize: "12px", //动画开始的文字大小
endSize: "30px", //动画结束的文字大小
interval: 600, //动画时间间隔
color: "red", //文字颜色
callback: function() {} //回调函数
}, options);
$("body").append("<span class='num'>"+ options.str +"</span>");
var box = $(".num");
var left = options.obj.offset().left + options.obj.width() / 2;
var top = options.obj.offset().top - options.obj.height();
box.css({
"position": "absolute",
"left": left + "px",
"top": top + "px",
"z-index": 9999,
"font-size": options.startSize,
"line-height": options.endSize,
"color": options.color
});
box.animate({
"font-size": options.endSize,
"opacity": "0",
"top": top - parseInt(options.endSize) + "px"
}, options.interval , function() {
box.remove();
options.callback();
});
}
});
});
-----------------------------
上面获取的变量 numid,怎样可以在下面使用:
$("body").append("<span class='num'>"+ options.str +"</span>");
var box = $(".num");
里面的 class='num'
box = $(".num"); 展开
$(document).delegate(".sf-praise-list li","hover",function(event) {
$(this).toggleClass("sf-praise-item-hover");
});
$(document).delegate(".sf-praise-list li","click",function(event) {
var read=$(this).attr("data-read");
var postid=$(this).attr("data-postid");
var value=$(this).attr("data-value");
var numid = "num"+postid;
if(read=="1"){
alert("你已经投过一次了,还想投么( ̄口 ̄)!!!");
return;
}else{
$.ajax({
type:'post',
async:true,
url:bloghost + "zb_users/plugin/sf_praise/save.php",
data:{
sf_praise_value:value,
postid:postid
},
timeout:30000,
dataType:'html',
complete:function(){
},
success:function(data){
if(data=="ok"){
var ob=$(".sf-praise-list li[data-value='"+value+"']").find("span[type='"+numid+"']");
var sint=parseInt(ob.html(),10);
sint++;
ob.html(sint);
$.tipsBox({
obj: $(".sf-praise-list li[data-value='"+value+"']"),
str: "+1"
});
}else{
alert("你已经投过一次了,还想投么( ̄口 ̄)!!!");
}
}
});
}
});
$.extend({
tipsBox: function(options) {
options = $.extend({
obj: null, //jq对象,要在那个html标签上显示
str: "+1", //字符串,要显示的内容;也可以传一段html,如: "<b style='font-family:Microsoft YaHei;'>+1</b>"
startSize: "12px", //动画开始的文字大小
endSize: "30px", //动画结束的文字大小
interval: 600, //动画时间间隔
color: "red", //文字颜色
callback: function() {} //回调函数
}, options);
$("body").append("<span class='num'>"+ options.str +"</span>");
var box = $(".num");
var left = options.obj.offset().left + options.obj.width() / 2;
var top = options.obj.offset().top - options.obj.height();
box.css({
"position": "absolute",
"left": left + "px",
"top": top + "px",
"z-index": 9999,
"font-size": options.startSize,
"line-height": options.endSize,
"color": options.color
});
box.animate({
"font-size": options.endSize,
"opacity": "0",
"top": top - parseInt(options.endSize) + "px"
}, options.interval , function() {
box.remove();
options.callback();
});
}
});
});
-----------------------------
上面获取的变量 numid,怎样可以在下面使用:
$("body").append("<span class='num'>"+ options.str +"</span>");
var box = $(".num");
里面的 class='num'
box = $(".num"); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询