Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从document.getElementById.setAttribute href添加按钮或将长url更改为其他名称_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何从document.getElementById.setAttribute href添加按钮或将长url更改为其他名称

Javascript 如何从document.getElementById.setAttribute href添加按钮或将长url更改为其他名称,javascript,jquery,html,Javascript,Jquery,Html,我想问:我创建了一个带有一些值的选择选项,例如: 函数更新输入(e){ var-selectedOption=e.target.options[e.target.selectedIndex]; var url=selectedOption.getAttribute('data-url'); document.getElementById('data1')。value=selectedOption.getAttribute('data1'); document.getElementById('d

我想问:我创建了一个带有一些值的选择选项,例如:

函数更新输入(e){
var-selectedOption=e.target.options[e.target.selectedIndex];
var url=selectedOption.getAttribute('data-url');
document.getElementById('data1')。value=selectedOption.getAttribute('data1');
document.getElementById('data2')。value=selectedOption.getAttribute('data2');
document.getElementById('data3')。value=selectedOption.getAttribute('data3');
document.getElementById('data4')。value=selectedOption.getAttribute('data4');
document.getElementById('data5')。value=selectedOption.getAttribute('data5');
document.getElementById('data-url').setAttribute('href',url);
document.getElementById('data-url')。innerHTML=url;
}

30天
60天
锚定
您可以设置锚定的样式
在这种情况下,您的链接将像一个按钮…

我希望这就是您正在寻找的。将按钮类添加到

函数更新输入(e){
var-selectedOption=e.target.options[e.target.selectedIndex];
var url=selectedOption.getAttribute('data-url');
document.getElementById('data1')。value=selectedOption.getAttribute('data1');
document.getElementById('data2')。value=selectedOption.getAttribute('data2');
document.getElementById('data3')。value=selectedOption.getAttribute('data3');
document.getElementById('data4')。value=selectedOption.getAttribute('data4');
document.getElementById('data5')。value=selectedOption.getAttribute('data5');
document.getElementById('data-url').setAttribute('href',url);
document.getElementById('data-url')。innerHTML=url;
}
。按钮{
显示:内联块;
填充:6px 12px;
页边距底部:0;
字体大小:14px;
字体大小:400;
线高:1.42857143;
文本对齐:居中;
空白:nowrap;
垂直对齐:中间对齐;
-ms触摸动作:操作;
触摸动作:操作;
光标:指针;
-webkit用户选择:无;
-moz用户选择:无;
-ms用户选择:无;
用户选择:无;
背景图像:无;
背景色:#ddd;
边框:1px实心#ddd;
边界半径:4px;
}

30天
60天

锚定
您也可以使用输入或Button元素来代替a标记

... <input id="data-url" type="button" onclick="data-url-location-href';" value="data-url" /> ....
。。。。
您只需要更新您的javascript

我想更改url或“收件人”按钮

只需用
如果你在
标签上提到目标,我想你可以解决这个问题

<a href="http://google.com" target="_blank" class="btn btn-default">Go to Google</a>

30天
60天

Anchor
只需使用
-元素并使用css或在
-标记之间设置样式,使其看起来像一个按钮。感谢先生的回复,我尝试添加不工作的sir感谢先生的回复,对不起先生,如何更改为Yahoo但仍然可以在按钮中单击?对不起先生可以再次询问,如何隐藏按钮“Anchor”如果没有select@umild我根据你的需要更新了这个片段,因为回答的延迟,我有点忙
<a href="http://google.com" target="_blank" class="btn btn-default">Go to Google</a>