- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
为什么以下内容没有将文本更改为有效?
//JAVASCRIPT/JQUERY:
$('a').each(function(i) {
if($(i).attr("href") == "mywebsite.co.uk")
{
$(i).innerHTML = "It Worked!";
}
});
//HTML:
<a href="mywebsite.co.uk"></a>
调试它似乎没有获取 href value.attr 但我可能弄错了有人可以确保我正确完成了上述操作吗?
最佳答案
i
是元素的索引,你想要元素并且应该使用应该使用类似的东西:
// The first argument is the index, the second is the element
$('a').each(function(index, element) {
if($(element).attr("href") == "mywebsite.co.uk")
{
$(element).html("It Worked!"); // Change this to .html()
}
console.log('Index is:'+index+', Element is'+element);
});
<a href="mywebsite.co.uk"></a>
此外,我更改了 .innerHtml()
至 .html("content in here")
.更新返回的 <a></a>
中的 HTML标签 (element)
.
关于jquery - 对于 href 等于 myValue 的每个链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12456890/
我是 JavaScript 新手。我相信这对于有经验的人来说会很容易。 Amazon AWS SDK for Node.JS 的 SimpleDB getAttributes 函数返回如下数据数组:
我有一个非常关键的代码。我试图从一个表的两列中选择与另一表的一列中的记录匹配的所有记录。这是我到目前为止的结果 SELECT username FROM users WHERE username NO
我有一个问题。我有一个对象列表(车辆)。 List vehicleList = Vehicle.GetVehiclesFromDatabase(); 现在我想要这样的东西: vehicleList.R
这个问题在这里已经有了答案: What is the difference between if(CONST==variable) or if(variable==CONST)? (5 个答案) 关
这是我的 HTML 代码 我想在加载页面时使用 JQuery 更改按钮的样式类。 要求:对于具有值“关闭”的按钮,样式类红色应替换为绿色。 注意:我无法更改上面的代码,因
为什么以下内容没有将文本更改为有效? //JAVASCRIPT/JQUERY: $('a').each(function(i) { if($(i).attr("href") == "myweb
为了从数组中抓取一个项目,抓取一个项目的值必须是一个整数。像这样: var myArray = ["apples", "oranges", "sugar", "onions", "steak"]; a
我有以下代码: List productGroupProductDataList = FillMyList(); string[] excludeProductIDs = { "871236", "2
我试图使用 从我的 child.jsp 获取值到我的 parent.jsp var myvalue = window.opener.document.getElementById(“parentId1
我试图从我的 child.jsp 获取值到我的 parent.jsp 使用 window.opener.document.getElementById("parentId1").value = myv
我有一些旧版 python 脚本,用于管理我在 Linux (bash) 和 Windows (cmd.exe) 上运行的所有程序和插件的 shell 环境。我想将其移植到 powershell。 如
我正在创建一个自定义的“PageHeaderControl”用户控件,带有标题属性: public partial class PageHeaderControl: UserControl {
有没有办法加入 2 个表,在 2 个表之间的列上添加条件? 例子 : case class TableA(pkA: Int, valueA: Int) case class TableB(pkB: I
我有一个 Controller 将逻辑寻找: session 值 //checks value null etc.. for existing record in session memory.
我正在尝试为 创建一个 std::map . MyKey是一个枚举,MyValue一个外部类。 调用 myMap.insert({ key, value })编译总是出错 "cannot conve
我是一名优秀的程序员,十分优秀!