I have many image elements and want to get a specific image’s source where the alternative text is “example”.
I tried this:
var src = $('.conversation_img').attr('src');
but I can’t get the one I need with that.
How do I select a specific image element based on its alternative text?
To select and element where you know only the attribute value you can use the below jQuery script
Please refer the jQuery Documentation for attribute equals selectors
Please also refer to the example in Demo
Following is the code incase you are not able to access the demo..
HTML
SCRIPT JQUERY
Output will be
Two Alert messages each having values
\images\showAll.jpg