有人能告诉我为什么这个jquery不起作用吗?
<script type="text/javascript">
jQuery('a').each(function(){
jQuery("#get-pricing-now-button-hotfix8").attr("href", "/en/starting-prices/");
});
</script>
我在页面上有几个按钮的id值为get-pricing-now-button-hotfix8,我需要这些链接的ahref值切换到/en/starting prices/。
我能够使用下面的一个链接使其工作,但只更改了一个按钮。
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#get-pricing-now-button-hotfix8").attr("href","/en/starting-prices/");
});
</script>
请帮忙!
感谢@cloned为我指明了正确的方向。
最后,我使用了这段代码和任何新URL的实例。
我将#get-pricing-now-button-hotfix8更改为.get-pricing-now-button-hotfix8(从ID更改为类(
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".get-pricing-now-button-hotfix8").attr("href","/en/starting-prices/");
});
</script>