I have two functions that do the same thing, except the element I am targeting is different and so is the ID I want to add. What is the best way to combine these into a single function?
<script>
$('.Index-page--has-image[id*="angle-right"]').each(function(){
var index = $(this).index('.Index-page--has-image')
$('.Parallax-host .Parallax-item').eq(index).attr('id','angle-right');
});
$('.Index-page--has-image[id*="angle-left"]').each(function(){
var index = $(this).index('.Index-page--has-image')
$('.Parallax-host .Parallax-item').eq(index).attr('id','angle-left');
});
</script>