销毁/删除bootstrap轮播

时间:2017-08-14 09:09:02

标签: javascript jquery twitter-bootstrap-3 bootstrap-carousel

首先,我创建了一个虚拟轮播(轮播元素),然后将其初始化

cmake_minimum_required(VERSION 3.1.0)
project(project_name)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")

find_package(OpenGL REQUIRED)
find_package(FREEGLUT REQUIRED)
find_package(GLEW REQUIRED)

if(NOT ${OPENGL_FOUND})
    message("OPENGL not found")
endif()

include_directories(
    ${PROJECT_SOURCE_DIR}
    ${FREEGLUT_INCLUDE_DIR}
    ${GLEW_INCLUDE_DIR}
    ${OPENGL_INCLUDE_DIR}
    )

message(${OPENGL_INCLUDE_DIR})
add_executable(${PROJECT_NAME}  ${PROJECT_SOURCE_DIR}/filename.cpp) 
target_link_libraries(${PROJECT_NAME} 
${OPENGL_LIBRARY}
${FREEGLUT_LIBRARY}
${GLEW_LIBRARY}
)

现在,我运行的情况是,如果窗口宽度小于480,则移除该旋转木马(#first-carousel')。

如何删除bootstrap轮播?试图检查它的文档,但似乎没有像破坏或删除功能或任何相关的东西。试图

# Try to find the FREEGLUT library
#
# FREEGLUT_INCLUDE_DIR
# FREEGLUT_LIBRARY
# FREEGLUT_FOUND

FIND_PATH(
  FREEGLUT_INCLUDE_DIR GL/freeglut.h GL/gl.h GL/glu.h GL/glew.h
  ${CMAKE_INCLUDE_PATH}
  $ENV{include}
  ${OPENGL_INCLUDE_DIR}
  /usr/include
  /usr/local/include
)

SET(STORE_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
SET(CMAKE_FIND_FRAMEWORK NEVER)

FIND_LIBRARY(
  FREEGLUT_LIBRARY
  NAMES freeglut_static freeglut glut GL
  PATH
    /opt/local/lib
    ${CMAKE_LIBRARY_PATH}
    $ENV{lib}
    /usr/lib
    /usr/local/lib
)

SET(CMAKE_FIND_FRAMEWORK ${STORE_CMAKE_FIND_FRAMEWORK})

IF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY)
   SET(FREEGLUT_FOUND TRUE)
ENDIF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY)

IF (FREEGLUT_FOUND)
   IF (NOT FREEGLUT_FIND_QUIETLY)
      MESSAGE(STATUS "Found FREEGLUT: ${FREEGLUT_LIBRARY}")
   ENDIF (NOT FREEGLUT_FIND_QUIETLY)
ELSE (FREEGLUT_FOUND)
   IF (FREEGLUT_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Could not find FREEGLUT")
   ENDIF (FREEGLUT_FIND_REQUIRED)
ENDIF (FREEGLUT_FOUND)

但似乎没有用,相反它给了我这个错误

  

bootstrap.min.js:6未捕获的TypeError:无法读取属性   ' offsetWidth'未定义的           在c.slide(bootstrap.min.js:6)           在c.next(bootstrap.min.js:6)           在e(jquery.min.js:2)

任何帮助,想法?

2 个答案:

答案 0 :(得分:1)

在Boostrap 3中,显然没有办法做到这一点。只能在视口大于或等于480px的情况下初始化轮播。

if(window.innerWidth >= 480){
  $('#first-carousel').carousel();
}

答案 1 :(得分:-1)

代码$('#first-carousel').remove();会删除具有该ID的元素。您可能会遇到窗口宽度条件的问题,您确定此处没有其他问题吗?