Pretty much the title, good id you have a ton of the same divs and you need to append a common link or something.
Created
July 14, 2015 00:44
-
-
Save kruxor/adb96132c9a3a706ce8f to your computer and use it in GitHub Desktop.
Loop through divs with the same class name and append something
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class='click-target'>a click target</div> | |
<div class='click-target'>another click target</div> | |
<div class='click-target'>and another click target</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if($('.click-target').length) { | |
$(".click-target").each(function(){ | |
$(this).append("<p>Added!</p>"); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment