How to hang a reference to the div in jquery?

Good day!

There is an array of js
var myArray = [ "link":"url_1", "link":"url_2", "link":"url_3" ];

there's html:
the <div> block 1 </div>
the <div> block 2 </div>
the <div> block 3 </div>


need using jquery /or js on each block to hang each your link : unit 1 - url_1, unit 2 - url_2, unit 3 - url_3.
June 8th 19 at 17:00
4 answers
June 8th 19 at 17:02
Don't understand where the div from the url to push, but let's say:
$('div').each(function(i,el){
$(el).text(myArray[i].link);
});

api.jquery.com/jquery.each
June 8th 19 at 17:04
Writing to the phone, so schematically: div -> onclick window.location.href = "www.sample".
June 8th 19 at 17:06
var myArray = [ "url_1", "url_2", "url_3" ];

$('div').each(function(i) {
 $(this).wrap('<a href="' + myArray[i] + '"></a>');
});
June 8th 19 at 17:08
$('div').click(function(){
window.location.href = "sate.ru".
})//
or
$('div').each(function(index){
$('this').click(function(){
window.location.href = myArray[index];
})
});

Find more questions by tags jQueryJavaScript