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";
}
精彩评论