-1
如果我放入圖像的實際src,我可以使用該功能。我動態地從api中提取所有圖像。我遇到的問題是我需要以某種方式克隆/讀取圖像ID這就是動態的,這樣它會發布正確的圖片在框中的權利,如果你運行這個代碼沒有它只是做一個即時通訊。抓取動態圖像並將其複製到另一個div
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</style>
<script type="text/javascript" rel="script" type="script" href="script.jss"></script>
<script type="text/javascript" src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
<script type="text/javascript">
$(document).ready(function() {
var webaddress = '<img id= "[index]" src="http://pokeapi.co/media/img/[index].png">';
var pokelist = $('#pokelist'); // get your pokelist
for (var i = 1; i <= 152; i++) {
var image = webaddress.replace(/\[index\]/g, i); // escape your square brackets and make it a global replace
pokelist.append(image); // append it to div
}
});
$(document).on("click", '#pokelist', 'img', function() {
$("#deck1").append('<img src="http://pokeapi.co/media/img/1.png">');
});
</script>
</head>
<body>
<div id="wrapper">
</div>
<div id="pokedeck">
<div id="pokelist">
</div>
<div id="deck1"></div>
</div>
</div>
</body>
</html>
這一旦擔任它讓我病檢查它的權利。泰 –