Javascript 清除外部JS文件中的图像
我正在尝试使用外部jquery文件清除图像,但它甚至没有向我显示警报 这是我的div中需要清除的图像Javascript 清除外部JS文件中的图像,javascript,jquery,asp.net,image,external,Javascript,Jquery,Asp.net,Image,External,我正在尝试使用外部jquery文件清除图像,但它甚至没有向我显示警报 这是我的div中需要清除的图像 $('#<%=thumbs.ClientId%>').append("<img class='LoadclickImage' align='left' style='height:48px;width:75px;' src='Uploads/" + document.getElementById("<%=currentDirectory.ClientId%>").
$('#<%=thumbs.ClientId%>').append("<img class='LoadclickImage' align='left' style='height:48px;width:75px;' src='Uploads/" + document.getElementById("<%=currentDirectory.ClientId%>").value + "/" + file.name + "' width='75' height='50' rel='group1' href='Uploads/" + document.getElementById("<%=currentDirectory.ClientId%>").value + "/" + file.name + "' >");
$('#').append(“”.value+“/”+file.name+“'width='75'height='50'rel='group1'href='Uploads/“+document.getElementById(“”.value+“/”+file.name+“>”);
这是我的外部JS文件:
self.ClearAll_button.click(function (e) {
$('#<%=thumbs.ClientId%> img').hide;
alert('You have cleared everything!');
e.preventDefault();
}
self.ClearAll_按钮。单击(函数(e){
$('img')。隐藏;
警惕(“你已经清除了一切!”);
e、 预防默认值();
}
在外部javascript文件中没有什么意义。这是一个ASP.NET服务器端标记,只能在ASPX/ASCXWebForms中使用
一种可能是在ASPX页面中定义全局javascript变量:
<script type="text/javascript">
var thumbsId = '<%=thumbs.ClientId%>';
</script>
另一种可能是使用类选择器而不是id选择器。如果您在ASP.NET 4.0上运行,另一种可能是使用
ClientIDMode
设置。外部,您是指单独的.js文件吗?请显示实际的HTML(浏览器看到的内容),不是你的asp模板。你确定你的按钮不是空的吗?@Adreas是的,它是从一个外部的.js文件调用的。@Darin谢谢你的回复。它现在给我一个提醒,但不删除图像。@Darin-你的代码中有一个小的更正。对于“隐藏”,它应该是hide();
self.ClearAll_button.click(function (e) {
$('#' + thumbsId + ' img').hide();
alert('You have cleared everything!');
e.preventDefault();
}