hey there all,
can you kindly see the below and assist me.
I am getting the below error while using the code below-
" TypeError: Result of expression 'this.replace' [undefined] is not a function."
Here’s the code-
(function($){
$.fn.ToCode = function(){
return this.each(function(i){
var line = $(this).html().replace(/\n/g, "<li>").trim();
if (line.match("<li>") !== "<li>") tmp = "<li>" + line + "<\/li>";
$(this).html("<ol class=\"code\">" + tmp + "<\/ol>");
//$(".code li:nth-child(odd)").addClass("alt");
$(".code li:first-child, .code li:last-child").css("display","none");
});
};
})(jQuery);Have taken this from somewhere else and that is working fine there.
It has been stated as a substitute for some Javascript that edits code blocks to lists.
Its not functioning on my platform-
This is how it is called-
$(document).ready(function () {
//Code
$('code').ToCode();
...
});Gives this error -
"TypeError: Result of expression '$('code').ToCode' [undefined] is not a function."
Can u find the missing point ???
Thanks!
40 weeks 5 days ago