我一直试图让下面的代码工作。基本上我想要做的是在点击链接时交换输入框之间的文本。因此,从A到B和B到A的文本。关于如何解决这个问题或我在做什么错误的任何想法?
我已经试过以下:Jquery .click切换文本输入框
<script>
$("#switchdir").click(function()
{
$("#saddr").val($('#daddr').val());
$("#daddr").val($('#saddr').val());
}
</script>
<form action="directions1.php" method="get">
<h1><p>A: <input type="text" class="directionsdata" name="saddr" placeholder="Enter Address, business or landmark" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter Address, business or landmark'" style="color: CCCCCC; width:290px; height: 20px; padding:5px; border-radius: 5px; border-style: solid; border-color: #CCCCCC;" /></p></h1>
<h1><p>B: <input type="text" class="directionsdata" name="daddr" placeholder="Enter Address, business or landmark" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter Address, business or landmark'" style="width:290px; height: 20px;padding:5px; border-radius: 5px; border-style: solid; border-color: #CCCCCC;"/></p></h1>
<a href="#" id="switchdir">Switch</a>
<input type="submit" value="Get Directions" class="button"/>
</form>
感谢您的快速回复。我现在明白为什么它不起作用。再次感谢! – chriogenix