Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select alt attribute of a images

I have

   <div id="aa">
   <img src="." height="17" alt="example1" title="">
       <table>
            <tbody><tr>
              <th></th>
              <td></td>
       </tbody>
       </table>


   <img src="." height="17" alt="example2" title="">
       <table>
            <tbody><tr>
              <th></th>
              <td></td>
       </tbody>
       </table>


   <img src="." height="17" alt="example3" title="">
       <table>
            <tbody><tr>
              <th></th>
              <td></td>
       </tbody>
       </table>
   </div>

I only want to select the attributes "alt" values "example1, example2, example3" of images. How can I get them.

like image 278
user3898594 Avatar asked Dec 19 '22 11:12

user3898594


1 Answers

I presume you mean that you want to select all the images (in CSS) that contain example* in the alt attribute, so you can style them. (and that you don't mean that you actually want tot select the text set in the alt attribute)

You can use the attribute selector:

img[alt~="example"] {
    border: 1px solid red;
}
like image 133
LinkinTED Avatar answered Jan 19 '23 02:01

LinkinTED