简体   繁体   中英

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 .

In .each first argument should be function, like this

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

Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM