开发者

Changing the href attribute on checked

开发者 https://www.devze.com 2023-02-15 14:06 出处:网络
I\'m working on a web page that contains a radio buttons group. When one of these buttons get checked I need to change the href attribute of a link element (use different CSS file), How can I do tha

I'm working on a web page that contains a radio buttons group.

When one of these buttons get checked I need to change the href attribute of a link element (use different CSS file), How can I do that using Java script and html?

开发者_StackOverflow中文版

I tried getElementById() but the innerHtml attribute doesn't help, do you have any simple solution?


This should work:

document.getElementById('myStylesheet').href = 'http://example.com/new/href/link';


var input = document.getElementById("inputid");
if (input.checked){
var aElem = document.getElementById("aid");
aElem.href = "newurl";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消