我在应用程序中运行以下脚本时遇到问题。该操作无效我尝试以下列方式更改脚本
测试1
<script type="text/javascript">
$.noConflict();
$(document).ready(function () {
$('.deleterd').on('click', function(){
$(this).closest('div').remove();
});
</script>
测试2
<script type="text/javascript">
jQuery.noConflict();
(function( $ ) {
$('.deleterd').on('click', function(){
$(this).closest('div').remove();
});
</script>
测试3
jQuery(function($) {
$.noConflict();
$(document).ready(function () {
$('.deleterd').on('click', function(){
$(this).closest('div').remove();
});
没有冲突,没有冲突,但剧本仍无效。
当我在控制台中粘贴相同的脚本时,脚本运行正常。我尝试将脚本放在其他脚本的顶部,底部,中间但仍然没有用。任何帮助都非常感谢。
不,仍然无法正常工作。另外,我在浏览器控制台中收到错误&#34; TypeError:Undefined不是函数&#34;
答案 0 :(得分:0)
你缺少关闭括号..试试这个:
<script type="text/javascript">
$.noConflict();
$(document).ready(function () {
$('.deleterd').on('click', function(){
$(this).closest('div').remove();
});
});
</script>