Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

I have a <img>:

 <img src="http://xxxexample.com/mmm/01.jpg" class="test">

How can I check if the src is missing the 01.jpg and replace it with some other image?

Basically

if (img src is 'http://xxxexample.com/mmm/') { 
    replace src with 'http://xxxexample.com/mmm/test.jpg'
}

I have a <img>:

 <img src="http://xxx.com/mmm/01.jpg" class="test">

How can I check if the src is missing the 01.jpg and replace it with some other image?

Basically

if (img src is 'http://xxx.com/mmm/') { 
    replace src with 'http://xxx.com/mmm/test.jpg'
}

I have a <img>:

 <img src="http://example.com/mmm/01.jpg" class="test">

How can I check if the src is missing the 01.jpg and replace it with some other image?

Basically

if (img src is 'http://example.com/mmm/') { 
    replace src with 'http://example.com/mmm/test.jpg'
}
added 11 characters in body; edited title
Source Link
kapa
  • 78.9k
  • 21
  • 166
  • 178

jquery how jQuery - How to check if img src is emptylacks filename?

iI have a img<img>:

 <img src="http://xxx.com/mmm/01.jpg" class="test">

howHow can iI check if the src is missing the 01.jpg and replace it with some other image?

basically if (img src is 'http://xxx.com/mmm/'){replace src with 'http://xxx.com/mmm/test.jpg'}Basically

thanks

if (img src is 'http://xxx.com/mmm/') { 
    replace src with 'http://xxx.com/mmm/test.jpg'
}

jquery how to check if img src is empty?

i have a img:

 <img src="http://xxx.com/mmm/01.jpg" class="test">

how can i check if the src is missing the 01.jpg and replace it with some other image?

basically if (img src is 'http://xxx.com/mmm/'){replace src with 'http://xxx.com/mmm/test.jpg'}

thanks

jQuery - How to check if img src lacks filename?

I have a <img>:

 <img src="http://xxx.com/mmm/01.jpg" class="test">

How can I check if the src is missing the 01.jpg and replace it with some other image?

Basically

if (img src is 'http://xxx.com/mmm/') { 
    replace src with 'http://xxx.com/mmm/test.jpg'
}
Source Link
Patrioticcow
  • 27.1k
  • 76
  • 221
  • 342

jquery how to check if img src is empty?

i have a img:

 <img src="http://xxx.com/mmm/01.jpg" class="test">

how can i check if the src is missing the 01.jpg and replace it with some other image?

basically if (img src is 'http://xxx.com/mmm/'){replace src with 'http://xxx.com/mmm/test.jpg'}

thanks