Adam Jahur Adam Jahur - 1 year ago 89
HTML Question

how to link another html page to a poster image in jquery?

var columnBlock = $('<div class="col-md-2">');
var imagePoster = $('<img>');
var selectButton = $('<a href="secondPage.html"><button class="selectButton"></button></a>');

var movieID = results[i].id;

imagePoster.attr('movie-id', movieID);
imagePoster.attr('src', '' + results[i].poster_path);

selectButton.text("Select Movie");
selectButton.attr('movie-id', movieID);


I want to make the imagePoster link to the secondPage.html and i tired the same method as i did with the button but it takes away all the poster images on the page.

Answer Source

Delete this one: columnBlock.append(imagePoster);

Add this : var imagePoster_link = $('<a href="AnOtHeR.UrL">');
And this: imagePoster_link.append(imagePoster);
And this : columnBlock.append(imagePoster_link);

Just before : columnBlock.append(selectButton); (unchanged)

In short it puts your img inside an ancor element before happending it to the document.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download