我有一些图像及其翻转图像.使用jQuery,我想在onmousemove/onmouseout事件发生时显示/隐藏翻转图像.我的所有图像名称都遵循相同的模式,如下所示:
原始图片:
Image.gif翻转图像:
Imageover.gif
我想分别在onmouseover和onmouseout事件中插入和删除图像源的"over"部分.
我怎么能用jQuery做到这一点?
最后的错误是什么?谢谢.
window.addEventListener('load', function() {
alert("All done");
}, false);
Run Code Online (Sandbox Code Playgroud) 我正在使用Bootstrap 3.1.0在一个站点上工作.
你会注意到当模态窗口打开时,浏览器滚动条会暂时消失,然后返回.关闭它时也会这样做.
我怎样才能使它只是打开和关闭而没有浏览器滚动条交互.我已经看到人们遇到问题的堆栈上的帖子,但我找不到特定于我的问题的答案,所以如果其他人提出了这个请求并且有人知道并且想要将我链接到它,我会很感激它.在发布之前我已经搜索了大约2个小时.
html5 responsive-design twitter-bootstrap twitter-bootstrap-3
Bootstrap模态事件多次触发,或者更确切地说是之前的一次.我将模态事件包装在一个click函数中,该函数现在返回模态id.
如何确保事件始终只触发一次,并且只有当click函数调用它时?
jQuery的
$('.img-modal').on('click', function () {
// returns #modal-Id
var modalIdClicked = $(this).attr('data-target')
console.log ('modal id clicked from .img-modal = '+ modalIdClicked);
console.log ('.img-modal clicked');
$(modalIdClicked).on('show.bs.modal', function(event) {
console.log ( 'show.bs.modal');
});
});
Run Code Online (Sandbox Code Playgroud)
默认Bootstrap 3.3.2模态HTML
<div class="col-md-7">
<img class="img-modal img-responsive cursor-pointer" data-toggle="modal" data-target="#modal-1" src="www" alt="image">
</div>
<!-- Modal -->
<div class="modal fade top-space-0" id="modal-1" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content cursor-pointer" data-toggle="modal" data-target="#modal-1">
<div class="modal-header">
<button type="button" class="close" data-dismiss="#modal-1">CLOSE ×</button>
<h1 class="modal-title">Modal Title</h1>
</div>
<div class="modal-body">
<div …Run Code Online (Sandbox Code Playgroud) 使用PhotoSwipe缩略图库标记如下所示:
<div class="wrap clearfix">
<div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery">
<ul class="gallery-grid">
<li>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="img/dektop/1.jpg" itemprop="contentUrl" data-size="1200x1200">
<img src="img/thumb/1.jpg" itemprop="thumbnail" alt="Image description" />
</a>
<figcaption itemprop="caption description">Image caption 1</figcaption>
</figure>
</li>
<li>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="img/dektop/2.jpg" itemprop="contentUrl" data-size="1200x1200">
<img src="img/thumb/2.jpg" itemprop="thumbnail" alt="Image description" />
</a>
<figcaption itemprop="caption description">Image caption 2</figcaption>
</figure>
</li>
</ul>
</div> <!-- mygallery -->
</div> <!-- wrap -->
Run Code Online (Sandbox Code Playgroud)
解析图像的功能是:
var parseThumbnailElements = function(el) {
var thumbElements = el.childNodes,
numNodes = thumbElements.length,
items = …Run Code Online (Sandbox Code Playgroud) 我正在建立一个寻呼机网站.例如.每个页面(总共5个)位于一个大页面上,主菜单固定在顶部.当您单击菜单链接时,它会将您向下滑动到该页面锚标记,并且单击的菜单项将获得"活动"CSS类.
我现在要做的是允许用户滚动自己,但仍然有菜单"活动"项和URL哈希更改.
所以我的问题基本上是如何知道用户何时向下滚动到不同的页面,以便我可以更新菜单和URL哈希(片段标识符).
谢谢
使用Blueimg Gallery我想知道如何总是显示图库控件(.blueimp-gallery-controls),而不是img class=".slide-content"在图库中单击时显示和隐藏它们.
看看blueimp-gallery.min.js(我用在线JavaScript美化器进行了美化,我找到了几个点击处理程序,同时也指示了图库控件的切换功能.
toggleControls: function() {
var a = this.options.controlsClass;
this.container.hasClass(a) ? this.container.removeClass(a) : this.container.addClass(a)
},
Run Code Online (Sandbox Code Playgroud)
在我看来,简单地评论这4行给了我想要的行为.但是我真的不想改变原始脚本.
这样做也会在脚本的这一部分内的Uncaught TypeError: undefined is not a function最后(this.toggleControls())处抛出错误.
f(c.toggleClass) ? (this.preventDefault(b), this.toggleControls()) : f(c.prevClass) ? (this.preventDefault(b), this.prev()) : f(c.nextClass) ? (this.preventDefault(b), this.next()) : f(c.closeClass) ? (this.preventDefault(b), this.close()) : f(c.playPauseClass) ? (this.preventDefault(b), this.toggleSlideshow()) : e === this.slidesContainer[0] ? (this.preventDefault(b), c.closeOnSlideClick ? this.close() : this.toggleControls()) : e.parentNode && e.parentNode === this.slidesContainer[0] && (this.preventDefault(b), …Run Code Online (Sandbox Code Playgroud) 我在Windows 7上安装了Python 3.4.1,包含了pip,在安装过程中选择了将python.exe添加到PATH.
运行pip安装请求时,我得到:
C:\Python34>pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in c:\python3
4\lib\site-packages
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\shutil.py", line 370, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\User\\AppData\\Local
\\Temp\\pip_build_User\\pip\\pip\\_vendor\\distlib\\w32.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 302, in run
requirement_set.cleanup_files(bundle=self.bundle)
File "C:\Python34\lib\site-packages\pip\req.py", line 1333, in cleanup_files
rmtree(dir)
File …Run Code Online (Sandbox Code Playgroud) 通过调用没有括号的函数来阅读它在注释和答案中多次声明不在生产中使用这样的代码.告诉我为什么?
我是JavaScript的初学者,你可以从这个问题中猜出来.如果有人可以用外行的话来表达他们的回答,那将是很好的,但请也请与经验丰富的JS人员讨论,他们可能需要更详细和技术上更详细的回复.
在生产中使用没有括号的函数可能出现或出错的例子将是答案的一个很好的补充.
下面是调用函数的示例代码,没有从该问题的答案中取出括号.
var h = {
get ello () {
alert("World");
}
}
Run Code Online (Sandbox Code Playgroud)
运行此脚本只需:
h.ello // Fires up alert "world"
Run Code Online (Sandbox Code Playgroud)
要么
var h = {
set ello (what) {
alert("Hello " + what);
}
}
h.ello = "world" // Fires up alert "Hello world"
Run Code Online (Sandbox Code Playgroud) javascript ×4
jquery ×4
html ×2
arrays ×1
assembly ×1
blueimp ×1
exception ×1
html-parsing ×1
html5 ×1
linux ×1
photoswipe ×1
pip ×1
python ×1
url ×1