尝试从两个输入字段,标题和链接文本生成链接。它应该在您键入时生成。这是我到目前为止所得到的:
<input type="text" id="title" value="" placeholder="Paste title"/><br>
<input type="text" id="link" value="" placeholder="Paste link"/>
<br>
<br>
Title: <span id="text_1"></span>
<script type="text/javascript">
$("#title").keyup(function() {
$("#text_1").text($("#title").val());
})
</script>
<br>
<br>
Link <span id="text_1_link"></span>
<script type="text/javascript">
$("#link").keyup(function() {
$("#text_1_link").text($("#link").val());
})
</script>
<br>
<br>
Combined here:
答案 0 :(得分:0)
我认为你喜欢这样的事情:
$("#link").keyup(function() {
$("#text_1_link").text($("#link").val());
$(".link").attr('href',$("#link").val());
})
$("#title").keyup(function() {
$("#text_1").text($("#title").val());
$(".link").text($("#title").val());
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input type="text" id="title" value="" placeholder="Paste title"/><br>
<input type="text" id="link" value="" placeholder="Paste link"/>
<br>
<br>
Title: <span id="text_1"></span>
<br>
<br>
Link <span id="text_1_link"></span>
<br>
<br>
Combined here: <a href="#" class="link"></a>
&#13;