How can I use function result to data-src value

Viewed 10
function goto_1_HQP()
{
var new_location = get_hqp_1_url(selected_pix_main);
top.location     = new_location;
}

function get_hqp_1_url(img_element)
{
var result     = img_element.match(/https:\/\/[a-zA-Z\.\/0-9-]+/i);
var pieces     = result[0].split("/");
var dir        = pieces[3];
var img_name   = pieces[5];
var img_pieces = img_name.split(".");
var img_id     = img_pieces[0];
var new_url    = 'https://globephoto.hu/' + dir + '/pPic/' + img_id + '.jpg';
return new_url;
}

The 2 functions here above are perfectly running with another .js and related image array I’d like to use return value of the function just here above (new_url - it’s an image url) in the code here below:

setAttribute('data-src', new_url); 
}

How can I do it? Thanks in advance

0 Answers
Related