0
我想使用jquery將唯一的passnum值傳遞給不同的區域信息,以便passnum信息特定於特定的區域。 例如zone1可能passnum = 100,zone2可能有50如何使用jquery從不同區域獲取價值?
是否有可能將唯一的passnum值傳遞到基於區域的每個區域<h5> </h5>
使用jquery?因爲可以動態創建數百個區塊。
<div class="wrapper" class="zone1">
other divs here (could have unknown amount of div block or tages here
<div ><span class="pass-num"><h5>some num </h5></span> </div>
</div>
<div class="wrapper" class="zone2">
other divs here (could have unknown amount of div block or tages here
<div><span class="pass-num"><h5>some num(pass val here) </h5></span> </div>
</div>
I have cthe ode below which works when u know the zone and structure
$(document).ready(function() {
var passnum ="110";
var passtext="All";
$('div.pass-text>h4').text(passtext);
$('div.pass-num>h4').text(passnum);
});
</script>
只是說,ID必須是唯一的單頁。 –
這個選擇器'$('div.pass-num> h4')'試圖用'pass-num'類來選擇'div',並在子節點中找到'h4'。也許你想寫這個:'$('span.pass-num> h5')'? – webdeveloper