我一直試圖讓下面的代碼工作。基本上我想要做的是在點擊鏈接時交換輸入框之間的文本。因此,從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