dimanche 4 mars 2018

Change child of certain parents with jquery

1U have a file directory with multiple files. I need to change the mime-type-icons of some files, as the default ones aren't specifically enough. I also have to insert the code via jquery, because I cannot change the mimetype-function.

My HTML looks like this:

<tr data-file="filename.psd" data-mime="application/octet-stream">
  <td class="td_01">
    <a class="name">
      <div class="thumbnail" style="background-image:url(/img/filetypes/image.svg)"></div>
    </a>
  </td>
</tr>

<tr data-file="filename.sketch" data-mime="application/octet-stream">
  <td class="td_01">
    <a class="name">
      <div class="thumbnail" style="background-image:url(/img/filetypes/image.svg)"></div>
    </a>
  </td>
</tr>

As you see, the thumbnail of my photoshop-file and of my sketch-file are the same.

Now, I want to change the 'style' attribute of the child div related to the file-extension. If the extension of the data-file-attribute is .psd > then change div#thumbnail's style-attribute to .../filetypes/psd.svg. If data-file-attribute is .sketch > div#thumbnails's stle-attribute should be .../filetypes/sketch.svg. And so on...

How can this be done? Any ideas? I am new to jQuery.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire