Trying to implement onclick tag load for multiple button components in AEM Need suggestion on bestpractices. below is the method I have implemented. Can some one please help me with this. Thanks in advance!
<sly data-sly-test="${properties.tag}">
<script>
$(".input1-tag").click(function(e){
e.preventDefault();
var href = $(this).attr("href");
$("body").append("<img src=\" ${properties.tag @ context ='scriptString'} \" width="1" height="1" alt="" />");
window.location = href;
});
</script>
</sly>
<sly data-sly-test="${properties.optionaltag}">
<script>
$(".input2-tag").click(function(e){
e.preventDefault();
var href = $(this).attr("href");
$("body").append("<img src=\" ${properties.optionaltag @ context ='scriptString'} \" width="1" height="1" alt="" />");
window.location = href;
});
</script>
</sly>
<sly data-sly-test="${properties.thirdtag}">
<script>
$(".input3-tag").click(function(e){
e.preventDefault();
var href = $(this).attr("href");
$("body").append("<img src=\" ${properties.thirdtag @ context ='scriptString'} \" width="1" height="1" alt="" />");
window.location = href;
});
</script>
</sly>