PDA

View Full Version : سوال: رفع مشکل سورس مربوطه



soroush.r70
چهارشنبه 01 شهریور 1391, 17:14 عصر
دوستان در کد زیر در خط ;var colors = new Array مشکل وجود داره چطوری می تونم آرایه رو کامل کنم و یه مشکل دیگه اینه که وقتی سورس زیر رو به سایتم اضلفه می کنم سایت بهم می ریزه

////////////////sheet//////////////////
$("document").ready(function() {
var colors = new Array;

// Disable all .switch stylesheets and build array of colours
$(".switch[rel='stylesheet']").each(function() {
$(this).attr("disabled", "true");
colors.push($(this).css("color"));
});


$(colors).each(function(index, el) {
$("#sheetswitch").append("<a class='swatch' style='background-color:" + el + ";'></a>");
});

$("#sheetswitch").append("<a href='#' class='sheetswitch_next'></a>");

$(".swatch").click(function() {
$(".swatch").removeClass("swatch_hi");
$(this).addClass("swatch_hi");
var index = $(".swatch").index(this);
$(".switch[rel='stylesheet']").attr("disabled", "true");
$(".switch[rel='stylesheet']").eq(index).attr("disabled", "");
$.cookie('mysite_sheetswitch_idx', index, {expires: 7});
});

$(".sheetswitch_next").click(function() {
var selected = $(".switch[rel='stylesheet']").filter(function () { return $(this).attr("disabled") === false; });
var current_idx = $(".switch[rel='stylesheet']").index($(selected));
var length = $(".switch[rel='stylesheet']").size();

if (current_idx >= 0) {
var next = current_idx + 1;
if (next > (length - 1)) next = 0;

$(".switch[rel='stylesheet']").attr("disabled", "true");
$(".switch[rel='stylesheet']").eq(next).attr("disabled", "");

$(".swatch").removeClass("swatch_hi");
$(".swatch").eq(next).addClass("swatch_hi");

$.cookie('mysite_sheetswitch_idx', next, {expires: 7});
}

return false;
});

$(".sheetswitch_prev").click(function() {
var selected = $(".switch[rel='stylesheet']").filter(function () { return $(this).attr("disabled") === false; });
var current_idx = $(".switch[rel='stylesheet']").index($(selected));
var length = $(".switch[rel='stylesheet']").size();

if (current_idx >= 0) {
var next = current_idx - 1;
if (next == -1) next = (length - 1);

$(".switch[rel='stylesheet']").attr("disabled", "true");
$(".switch[rel='stylesheet']").eq(next).attr("disabled", "");

$(".swatch").removeClass("swatch_hi");
$(".swatch").eq(next).addClass("swatch_hi");

$.cookie('mysite_sheetswitch_idx', next, {expires: 7});
}

return false;
});

if ($.cookie('mysite_sheetswitch_idx')) {
var idx = $.cookie('mysite_sheetswitch_idx');
$(".switch[rel='stylesheet']").eq(idx).attr("disabled", "");
$(".swatch").eq(idx).addClass("swatch_hi");
}
});

Variable
چهارشنبه 01 شهریور 1391, 21:33 عصر
شما برای تعریف ارایه یا باید از ()var colors = new Array; استفاده کنی یا از []=var colors
پیشنهاد میکنم برای استفاده از ارایه از [] استفاده کنی

Variable
چهارشنبه 01 شهریور 1391, 21:33 عصر
شما برای تعریف ارایه یا باید از ()var colors = new Array; استفاده کنی یا از []=var colors
پیشنهاد میکنم برای استفاده از ارایه از [] استفاده کنی

soroush.r70
پنج شنبه 02 شهریور 1391, 15:33 عصر
یعنی فقط بنویسم

var colors = new Array[];

Variable
پنج شنبه 02 شهریور 1391, 19:16 عصر
نه دوست من


var arr1=new Array();

var arr2=[];


ارایه اول . ایجاد ارایه بوسیله شی ارایه است
ارایه دوم . ایجاد ارایه با استفاده از [] که به این میگن array litteral