JavaScript密码+按钮打开目标元素中的URL
我学会了如何使用密码和按钮打开链接。 我使用以下代码:
<input type="text" id="text" />
<input type="button" id="btn" value="Submit" onClick="window.location=url;" />
<script>
$("#btn").click(function() {
window.location="example.com/"+$("#text").val();})
</script>
我想弄清楚的是,我是否可以针对DIV元素以进行内部打开的链接。
我一直在使用以下脚本将html页面加载到带有链接的指定div元素中:
<div class="item1" id="pageone"></div>
<a href="" onclick="loadSAMEDiv1(); return false;">link</a>
<script>
function loadSAMEDiv1() {
$.ajax({
url: 'item1.html',
success: function(data) {
$('#pageone').html(data);
}
});
}
</script>
我想我想知道是否有一种方法可以使第一个脚本在目标div中打开的密码URL,就像它一样在第二个脚本中。因此,当您单击按钮元素时,它将使用输入文本框中的密码将URL变为URL,然后将其加载到#PageOne之类的Div中。
I learned how to open a link using a password and button.
I used the following code:
<input type="text" id="text" />
<input type="button" id="btn" value="Submit" onClick="window.location=url;" />
<script>
$("#btn").click(function() {
window.location="example.com/"+$("#text").val();})
</script>
What I would like to figure out is whether I can target a div element for the link to open within.
I've been using the following script to load html pages into a specified div element with a link:
<div class="item1" id="pageone"></div>
<a href="" onclick="loadSAMEDiv1(); return false;">link</a>
<script>
function loadSAMEDiv1() {
$.ajax({
url: 'item1.html',
success: function(data) {
$('#pageone').html(data);
}
});
}
</script>
I guess I'm wondering if there's a way to make the password url made by the first script open in a targeted div, like it does in the second script. So when you click the button element it will make the url using the password entered into the text box and load it into a div like #pageone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是使用 Ajax
load()
。试试这个。The simplest way to do this is with Ajax
load()
. Try this.