Setting Target Links in Repeater

I have set a repeater on a page linked to a database. The repeater itself has four separate graphic elements, each linked to an URL field in a database. All of the links work, but some of the links open in a new window and others open in the same window. How can we change the target value of a link within the repeater whereas all of the links open in a new window?

There’s an easy solution (using code) if these elements are buttons or images. If they are not buttons or images it might be problematic.

To open in a separate tab:

$w.onReady(function () {
    $w("#repeater1").onItemReady(($item, itemData, index) => {
        $item("#button1").target = "_blank";
    })
});

To open in the same tab:

$w.onReady(function () {
    $w("#repeater1").onItemReady(($item, itemData, index) => {
        $item("#button1").target = "_self";
    })
});