<script type="text/javascript">
(function($){
var names = [],
hrefs = [];
newHTML1 = [];
newHTML2 = [];
$('#entry').find('a[href*=#]').each(function() {
hrefs.push(this.href.split('#')[1]);
}).end().find('a[name]').each(function() {
names.push(this.name);
});
/*$.each(hrefs, function(index, value) {
newHTML1.push('<span>' + value + '</span><br />');
});
$.each(names, function(index, value) {
newHTML2.push('<span>' + value + '</span><br />');
});
*/
//$(".entry").append(newHTML1.join("")).append(newHTML2.join(""));
function compare(arr_1, arr_2) {
var equal = arr_1.length == arr_2.length; // if array sizes mismatches, then we assume, that they are not equal
if (equal) {
$.each(arr_1, function (foo, val) {
if (!equal) return false;
if ($.inArray(val, arr_2) == -1) {
equal = false;
} else {
equal = true;
}
});
}
return equal;
}
var param = compare(names, hrefs);
if (param == true ) {
$('#entry').find('a[name]').addClass('anchor');
}
})(jQuery);
</script>
(function($){
var names = [],
hrefs = [];
newHTML1 = [];
newHTML2 = [];
$('#entry').find('a[href*=#]').each(function() {
hrefs.push(this.href.split('#')[1]);
}).end().find('a[name]').each(function() {
names.push(this.name);
});
/*$.each(hrefs, function(index, value) {
newHTML1.push('<span>' + value + '</span><br />');
});
$.each(names, function(index, value) {
newHTML2.push('<span>' + value + '</span><br />');
});
*/
//$(".entry").append(newHTML1.join("")).append(newHTML2.join(""));
function compare(arr_1, arr_2) {
var equal = arr_1.length == arr_2.length; // if array sizes mismatches, then we assume, that they are not equal
if (equal) {
$.each(arr_1, function (foo, val) {
if (!equal) return false;
if ($.inArray(val, arr_2) == -1) {
equal = false;
} else {
equal = true;
}
});
}
return equal;
}
var param = compare(names, hrefs);
if (param == true ) {
$('#entry').find('a[name]').addClass('anchor');
}
})(jQuery);
</script>
Комментарии
Отправить комментарий