views:

45

answers:

2

I have some contents inside div tag...

within that div tag content I have to search for img src tag value

based on that value i have to highlight some images and to show some div content

for example

if img src value contains "http://google.com/test/test.img" have to highlight and to show img is highlighted div content

if img src value contains some specific path "news/images/test1.jpg" have to highlight and to show img is highlighted div content

if img src value contains some specific path "news/articles/images/test1.gif" no need to highlight and to show img is not highlighted div content.

+2  A: 

I think you mean that there are two possible scenarios where you want to highlight the image:

var $img = $("#someImage");
var src = $img.attr("src");
if(src == 'http://google.com/test/test.img' || src == 'news/images/test1.jpg') {
    $img.addClass("highlight");
    // or
    $img.css("border", "3px solid yellow");
}

EDIT based on your comment:

$("#formpreview img[src*=google.com]").addClass("highlight");
karim79
Hi, Thanks for reply. <div id="formpreview"> dynamic content....... </div> I have to find the img src value within this div content and the content,img tags will be dynamic each time. There may be 10 images within that formpreview div tag. within the "formpreview" div tag content, I have to check all img src value and based on the src value, if it CONTAINS "google.com" i have to highlight that img and to show some content like "img is highlighted". if it not CONTAINS "google.com" i dont need to highlight and to show that content.
MKN
@MKN - You can filter them out by using the attribute contains selector. I've updated my answer, also http://api.jquery.com/attribute-contains-selector/
karim79
A: 
$('#someImage[url="http://google.com/test/test.img"],'
+ '#someImage[url="news/image/test1.jpg"]')
.addClass("highlight").css("border", "3px solid yellow");
CodeJoust