【发布时间】:2013-02-01 00:45:43
【问题描述】:
在我的https://getsatisfaction.com/gsfnmichelle/products 页面上,有一条面包屑路径写着“产品”。我正在尝试将其更改为“类别”。我可以在检查器中执行此操作,但是当我将代码放入自定义脚本(这只是我正在使用的平台上的主页 /gsfnmichelle)中时,它不起作用。
即使我能够获得正确的元素 (jQuery('.crumb_link span');) 并使用 (jQuery('.crumb_link span').text('Categories');) 更改它,我也可以'当它位于除主页面 (/gsfnmichelle) 之外的另一个页面 (/products) 中时,不知道如何更改它,因为这是我们可以插入自定义代码的唯一地方。
我认为这样的事情会检查页面并更改该元素,但它不起作用:
jQuery(document).ready(function () {
if (window.location.pathname =="/gsfnmichelle/products") {
jQuery('.crumb_link span').text('Categories');}
};
然后我尝试使用 if 语句来检查正确的元素,但这也不起作用:
jQuery(document).ready(function () {
if (jQuery('.crumb_link span').text =='Products') {
jQuery('.crumb_link span').text('Categories');}
};
我错过了什么?
【问题讨论】:
标签: javascript jquery html css dom