Title: Plugin doesn&#039;t recognise inserted HREFs
Last modified: September 1, 2016

---

# Plugin doesn't recognise inserted HREFs

 *  Resolved [Max](https://wordpress.org/support/users/beechboy707/)
 * (@beechboy707)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/plugin-doesnt-recognise-inserted-hrefs/)
 * Hello there!
 * Firstly beautiful plugin – thank you!
 * Though I have an issue that if I insert the URL into an HREF tag via Javascript
   when the document is ready, the plugin doesn’t recognise the image and so ignores
   the link. You can see this here, under the Gallery section: [http://pitfarmtennis.co.uk/home-test/](http://pitfarmtennis.co.uk/home-test/).
   
   The first 68 images work fine, as their links are already there, but if you click
   view more images, those images have had their links inserted via javascript, 
   as shown below, and so the plugin doesn’t seem to recognise them. Is there any
   way aroudn this please?
 * Very many thanks
 * <script type=”text/javascript”>
    jQuery(document).ready(function($) { <?php $
   imagesids2 = array_slice($imagesids, 8); ?> var images = [ <?php foreach( $imagesids
   as $imageid2 ): echo “‘” . wp_get_attachment_image_src( $imageid2, $size=’large’)[
   0] . “‘, “; endforeach; ?> ]; $(“.viewfullalbum<?php echo $albumcount; ?>”).click(
   function() { $(‘.gallery-album-contents-<?php echo $albumcount; ?> .gallery-photo’).
   each(function(i, obj) { $(obj).css(“background-image”, “url(“+images[i]+”)”);
   $(obj).parents().eq(1).attr(“href”, images[i]); });
 *  $(“.gallery-album-contents-<?php echo $albumcount; ?> .gallery-photo-container-
   parent”).css(“display”, “inline”);
    $(“.viewfullalbum<?php echo $albumcount; ?
   >”).css(“display”, “none”); }); }); </script> <?php $imagesids2 = array_slice(
   $imagesids, 8); ?> <?php foreach( $imagesids2 as $imageid2 ): ?> <div class=”
   gallery-photo-container-parent” style=”display: none;”> [“> <!– Javascript inserts
   href=”…” here –> <div class=”gallery-photo-container”> <div class=”gallery-photo”
   ></div><!– Javascript inserts style=”background-image: url(”)” here –> </div>
   </div> <?php endforeach; ?>
 * [https://wordpress.org/plugins/wp-featherlight/](https://wordpress.org/plugins/wp-featherlight/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Robert Neu](https://wordpress.org/support/users/fatmedia/)
 * (@fatmedia)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/plugin-doesnt-recognise-inserted-hrefs/#post-7615431)
 * Hey Beechboy,
 * This is a little bit outside of the scope of things that we’re able to provide
   support for, but I think what you’re going to need to do is re-fire featherlight
   on `ajaxComplete`
 * Something along these lines is probably what you’ll need to do in order to have
   those new DOM elements recognized: [http://stackoverflow.com/a/14692528](http://stackoverflow.com/a/14692528)
 * You could also try modifying the HTML in that gallery to include the [featherlight data attributes](https://github.com/noelboss/featherlight#usage)
   within them. I’m not sure if featherlight will recognize the added DOM elements
   or not because I haven’t tried it myself or dug through the code deep enough 
   to say whether it’s watching for DOM changes, but it’s worth a shot.
 * Hope that’s helpful!
 * – Rob
 *  Thread Starter [Max](https://wordpress.org/support/users/beechboy707/)
 * (@beechboy707)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/plugin-doesnt-recognise-inserted-hrefs/#post-7615445)
 * Hi Robert,
 * Very many thanks for the amazingly fast and helpful response!
    You are quite 
   right, adding data-featherlight=”image” to the a tag has done the trick – thank
   you so much!
 * I will be sure to leave a great review!
 * All the best.
 *  Plugin Author [Robert Neu](https://wordpress.org/support/users/fatmedia/)
 * (@fatmedia)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/plugin-doesnt-recognise-inserted-hrefs/#post-7615448)
 * Awesome! I’m glad that did the trick. I’ll make a note that it does in fact watch
   the DOM for new elements in the event that someone runs into a similar issue 
   in the future. 🙂
 *  Thread Starter [Max](https://wordpress.org/support/users/beechboy707/)
 * (@beechboy707)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/plugin-doesnt-recognise-inserted-hrefs/#post-7615541)
 * Great! You’re even more clever than you think!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Plugin doesn't recognise inserted HREFs’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-featherlight_121e24.svg)
 * [WP Featherlight - A Simple jQuery Lightbox](https://wordpress.org/plugins/wp-featherlight/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-featherlight/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-featherlight/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-featherlight/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-featherlight/reviews/)

## Tags

 * [firing](https://wordpress.org/support/topic-tag/firing/)
 * [href](https://wordpress.org/support/topic-tag/href/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [not](https://wordpress.org/support/topic-tag/not/)

 * 4 replies
 * 2 participants
 * Last reply from: [Max](https://wordpress.org/support/users/beechboy707/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/plugin-doesnt-recognise-inserted-hrefs/#post-7615541)
 * Status: resolved