当我点击按钮时,不会调用该功能
<script type="text/javascript">
$('#Add_Image').click(function () {
window.open('upload.html');
});
</script>
<button id="Add_Image" style="margin:10px; width:200px; height:35px; border-radius:8px;"> Add Image</button>
答案 0 :(得分:0)
将其写入文档准备部分:
$(document).ready(function(){
$('#Add_Image').click(function () {//you can use $('#Add_Image').on('click',function () { //also
window.open('upload.html');
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="Add_Image" style="margin:10px; width:200px; height:35px; border-radius:8px;"> Add Image</button>
&#13;
答案 1 :(得分:0)
以下对我来说很好...只需包装在document.ready中,并且不要在选择器名称上使用下划线或大写字母;-)。这将引发争论: - /
<script type="text/javascript">
$(document).ready(function(){
$('#add-image').on('click',function () {
window.open('upload.html');
});
});
</script>
<button id="add-image" style="margin:10px; width:200px; height:35px; border-radius:8px;"> Add Image</button>