[英]Alert showing when the page is loaded when I only want onclick
我有一個書簽系統,當一個圖像被添加了書簽時,我想要一個帶有圖像的警報以確認該圖像被添加了書簽。
我有一個有效的警報,並且onclick會顯示警報。 但是,警報也顯示頁面加載的時間。 我不知道如何僅在提交表單時顯示警報
編碼:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!--form which sends field information to the database-->
<form class="form" id="form" action="" method="post" >
<img id="enlargedSymbol" type="text" size="60" name="pathOfSymbol" src='' /> <!--large symbol where source is inserted-->
<br />
<!--hidden input which value is set by query where then its sent to the database-->
<input class="inputBox" type="hidden" name="pathOfSymbol" id="pathOfSymbol" />
<script>
var querySrc = URI(window.location.href).search(true).src; //gets image source
//sets image source as enlarged symbol
$("#enlargedSymbol").prop("src", querySrc);
//sets path of symbol as hidden value
$('#pathOfSymbol').val(querySrc);
</script>
<button type="submit" name="submit" id="addToBookmarksButton" onclick="addedToBookmarks()" >
<img id="addToBookmarksButton" src="img/addToBookmarks.png" />
</button>
</form>
<script>
$(function addedToBookmarks () {
$("#dialog").dialog();
});
</script>
<div id="dialog">
<img src="img/addToBookmarks.png" alt="Placeholder Image" />
</div>
<script>
$('#addToBookmarksButton').click(function(){
$("#dialog").dialog();
});
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.