Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: callback.apply is not a function

I've looked accross the web but did not find an answer to this question, where does this error could came from ?

Im working on a really simple code where I just replace some text by an other.

This is the HTML

<div class="imgLittle" style="background-image:url(http://voyagesarabais.com/1874431.jpg4fre);"</div>
<div class="imgLittle" style="background-image:url(http://voyagesarabais.com/159431.jpg4fre);"</div>

This is the jQuery

$(document).each('.imgLittle',function(){
  newLink =  $(this).css('background-image').replace(/^(.*?\.jpg).*/, "$1");
  $(this).css('background-image',newLink)
})

But when I run it it come out with this output :

Uncaught TypeError: callback.apply is not a function

You can have a look there : JsFiddle.

like image 581
Baldráni Avatar asked Feb 09 '23 16:02

Baldráni


1 Answers

In .each first argument should be function, like this

$('.imgLittle').each(function() {
  // your code
})

Example

like image 85
Oleksandr T. Avatar answered Feb 11 '23 15:02

Oleksandr T.