Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
194
rated 0 times [  199] [ 5]  / answers: 1 / hits: 26191  / 11 Years ago, thu, march 14, 2013, 12:00:00
<div class=s4-titlelogo>
<a href=/sites/mysite>
<img name=onetidHeadbnnr0 id=ctl00_onetidHeadbnnr2 style=border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; alt=bobpub src=/_layouts/images/blank.gif complete=complete/>
</a>
</div>


If the src attribute of the img is blank.gif, then i want to set the src attribute to my icon url /_layouts/images/myicon.gif. I need to reference the img as this $('.s4-titlelogo img').



SO FAR:



iconurl = $('.s4-titlelogo a>img').attr(src);
if (iconurl == /_layouts/images/blank.gif)
{

}

More From » jquery

 Answers
123

If the src attribute of the img is blank.gif...




if($('.s4-titlelogo img').attr('src') === '/_layouts/images/blank.gif')



...then i want to set the src attribute to my icon url.




$('.s4-titlelogo img').attr('src', '/_layouts/images/myicon.gif');


Edit: Three downvotes instantly? Uh... why?



Here's a JSFiddle example to prove that this works.


[#79590] Wednesday, March 13, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
karivictoriab

Total Points: 530
Total Questions: 90
Total Answers: 95

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;