Sandeep Shawn Tripathy Sandeep Shawn Tripathy - 11 months ago 47
jQuery Question

Add query string to Image Source(img src) if it has a particular class or ID

I want this in either PHP or JS. Its like, if img has particular class them a query string will be appended to its source url. Lets assume, the particular class is 'hello' & query string is '?source=fb'
So, if img has class 'hello' -

<img class="hello" src="">

The PHP should check & append it to the img src.

Any function that can do this?

Answer Source

<script src=""></script>
<img class="hello" src="">

Use like this