how to get img src value
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 a开发者_JAVA百科nd 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.
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");
$('#someImage[url="http://google.com/test/test.img"],'
+ '#someImage[url="news/image/test1.jpg"]')
.addClass("highlight").css("border", "3px solid yellow");
精彩评论