مالمشكلة في هذا الكود جيكوري ؟؟!

أردت انشاء كود يقوم باستبدال الساب دومين للروابط في الصفحة بشكل عشوائي

وكتبت هذه الاكواد

https://jsfiddle.net/uy5140sr

لكنها لم تعمل عندي

من فضلكم أين المشكلة


بهذذه الطريقه تستطيع تغيير الكلمه عشوائيا مع كل رابط هو نفس الكود الخاص بك لكن مع بعض التغيرات

$(document).ready(function() {

var sub = new Array("subdomain2", "subdomain3", "subdomain4", "subdomain");

/* $('.post-body').html(randno) */;

$(".post-body a" ).each(function() {

var randno = sub[Math.floor(Math.random()*(sub.length))];

var b = $(this).attr('href').replace('subdomain', randno)

$(this).attr('href', b);

});});

وهذا يغير الكلمه عشوائيا مع كل الروابط في كل مره يتم عمل reload للصفحه

$(document).ready(function() {

var sub = new Array("subdomain2", "subdomain3", "subdomain4", "subdomain");

/* $('.post-body').html(randno) */;
var randno = sub[Math.floor(Math.random()*(sub.length))];



$(".post-body a" ).each(function() {


var b = $(this).attr('href').replace('subdomain', randno)

$(this).attr('href', b);

});});