我有一个用Java脚本编写的轮播
我想将其父项create table tab_b(id int,
A_id int,
`key` varchar(20),
`value` varchar(20));
insert into tab_b values
(1,1,'text1','test_value1'),
(2,1,'text2','test_value2');
create table tab_a(id int,text1 varchar(20),text2 varchar(20));
insert into tab_a(id,text1,text2)
select id,max(text1) text1,max(text2) text2
from(
select a_id as id,
case when `key`='text1' then `value` end text1,
case when `key`='text2' then `value` end text2
from tab_b) a;
src
属性的img
标签的<a>
属性更改为“ true”。您能帮我吗,我实际上需要将"aria-selected"
的名称从img
更改为teacher.png
,所以我必须使用它的当前名称,并在其中添加teacher-active.png
值。
"-active"
// Handle setting the currently active link
pnProductNavContents.addEventListener("click", function(e) {
var links = [].slice.call(document.querySelectorAll(".pn-ProductNav_Link"));
links.forEach(function(item) {
item.setAttribute("aria-selected", "false");
})
e.target.setAttribute("aria-selected", "true");
// Pass the clicked item and it's colour to the move indicator function
moveIndicator(e.target, colours[links.indexOf(e.target)]);
});
答案 0 :(得分:0)
如果我理解正确性,则希望在当前item
范围内获取图像元素,并替换其src
。所以这样的事情应该起作用:
links.forEach(function(item) {
item.setAttribute("aria-selected", "false");
var image = item.querySelector('img');
var currentSrc = image.getAttribute('src');
var newSrc = currentSrc.replace('.png', '-active.png');
image.setAttribute('src', newSrc);
});