我的页面中有可调整大小的功能:
$(function() {
$( "#droppable" ).droppable({
create: function( event, ui ) {$( this ).hide(0)}
});
$( "#droppable" ).on( "dropover", function( event, ui ) { $( this )
$( this ).text('¿Eliminar?')} );
$( ".panel" ).draggable();
$( "#droppable" ).droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
drop: function( event, ui ) {
$(ui.draggable).toggle( "scale" );
$( this ).show(0).delay(700).toggle( "clip" );
$( this ).addClass( "ui-state-highlight" )
.text('¡Eliminado!')
}
});
$( "#droppable" ).on( "dropout", function( event, ui ) { $( this )
$( this ).text('Arrastrar y soltar para eliminar')} );
$( ".panel" ).resizable({
minHeight: 119,
minWidth: 352,
maxHeight: 219,
maxWidth: 452
});
});
但是我想只在分辨率超过1024时应用它。我应用它但这不起作用,它会抛出我的标记错误:
FULL ERROR:未捕获的SyntaxError:意外的令牌)
$(function() {
$( "#droppable" ).droppable({
create: function( event, ui ) {$( this ).hide(0)}
});
$( "#droppable" ).on( "dropover", function( event, ui ) { $( this )
$( this ).text('¿Eliminar?')} );
$( ".panel" ).draggable();
$( "#droppable" ).droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
drop: function( event, ui ) {
$(ui.draggable).toggle( "scale" );
$( this ).show(0).delay(700).toggle( "clip" );
$( this ).addClass( "ui-state-highlight" )
.text('¡Eliminado!')
}
});
$( "#droppable" ).on( "dropout", function( event, ui ) { $( this )
$( this ).text('Arrastrar y soltar para eliminar')} );
if ($(window).width() > 1024) {
$( ".panel" ).resizable({
minHeight: 119,
minWidth: 352,
maxHeight: 219,
maxWidth: 452
});
});
}
答案 0 :(得分:0)
你去了,你有语法错误,$(function(){=>(function(){,嵌套函数中的一些$(this)也会产生错误,而最后一个});在关闭之前完成if}
(function() {
$( "#droppable" ).droppable({
create: function( event, ui ){
$(this).hide(0);
}
});
$( "#droppable" ).on( "dropover", function( event, ui ) {
$( this ).text('¿Eliminar?');
});
$( ".panel" ).draggable();
$( "#droppable" ).droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
drop: function( event, ui ) {
$(ui.draggable).toggle( "scale" );
$(this).show(0).delay(700).toggle( "clip" );
$(this).addClass("ui-state-highlight").text('¡Eliminado!');
}
});
$("#droppable").on( "dropout", function( event, ui ) {
$(this).text('Arrastrar y soltar para eliminar');
});
if ($(window).width() > 1024) {
$( ".panel" ).resizable({
minHeight: 119,
minWidth: 352,
maxHeight: 219,
maxWidth: 452
});
}
});