jquery - Get Image Src from image title -


hi have strange requirement of getting image src image title using jquery. in case image title different there no possibility of same image title.

let me clarify question. here 1 image tag.

<img title="lion2" alt="lion2" src="http://localhost/test/img/co/122.jpg" class="awp_pcp_square_img"> 

i getting title lion2.

now want src of image tag. can not class there multiple image tag same class name.

you can use attribute equals selector [name="value"] element attribute , use attr() src value.

live demo

$('img[title=lion2]').attr('src'); 

description: selects elements have specified attribute value equal value.

you can use indexer [] dom element directly access attribute value without using attr()

$('img[title=lion2]')[0].src; 

Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -