0
我正在使用jQuery來使用$ .each函數更改所有定位標記的href屬性。 我可以在控制檯中獲取新的href,但點擊元素後,它不會重定向到已更改的新網址。無法使用jquery將新url加載到href屬性
$(".section-icons").each(function() {
var newHref = $(this).find("a").attr("href");
newHref += "?currentMod=sales_target";
console.log(newHref);
$(this).find("a").attr("href", newHref);
});
<div class="section-icons">
<a href="sales-target-revenue-wise.php">
<div class="modules-icons-dd">
<img src="<?=$dir_path?>images/module-icons/sales-target-revenue-wise-icon.png" />
</div>
<div class="section-text">Revenue Wise Sales Target</div>
</a>
</div>
Downvoter被包裹,小心地闡述? –
你怎麼能說OP沒有在DOM中包裝代碼? –
我可以這樣說,因爲他沒有把它包裹在問題中。爲什麼任何一個正確思想的人都會剝離他們的代碼並在SO上只粘貼部分代碼? –