我只是想使用javascript添加输入值。 这是priject link!>添加到购物车>继续结帐||然后您会看到结帐页面。
实际上,我想在结帐页面中自动添加Zipcode值。 我尝试过这种方法,但是没用
document.querySelector('#shipping-new-address-form div:nth-child(8) input').value = '12345';
任何人都可以帮助解决此问题吗?
答案 0 :(得分:0)
您可以使用chrome控制台来确保您的查询能够找到目标元素并设置其值,这完全是因为您的选择器可能不正确。
应该是这样
document.querySelector('input[name = "' + prop + '"]').setAttribute('placeholder', data[prop])
这里还有另一个类似的答案QuerySelector set text value
答案 1 :(得分:0)
在结帐页面上,您可以定义<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<StackPanel>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<TextBlock>aaaaaaaaaaaaaaaaaa</TextBlock>
<ScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto">
<StackPanel >
<TextBlock Foreground="Red">aaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccc dddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffff ggggggggggggggggggggggg</TextBlock>
<TextBlock Foreground="Red">aaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccc dddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffff ggggggggggggggggggggggg</TextBlock>
<TextBlock Foreground="Red">aaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccc dddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffff ggggggggggggggggggggggg</TextBlock>
<TextBlock Foreground="Red">aaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccc dddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffff ggggggggggggggggggggggg</TextBlock>
</StackPanel>
</ScrollViewer>
</StackPanel>
</ScrollViewer>
事件。
onload
答案 2 :(得分:0)
如果要使用JavaScript添加输入字段及其值,则可以使用以下脚本。
<script>
function myFunction()
{
var input = document.createElement("INPUT");
input.setAttribute("type", "text");
input.setAttribute("value", "1234");
document.body.appendChild(input);
}
myFunction();
</script>