0

The following code (Foundation 4, jQuery)

<script>
$(document).ready(function(){

    $("#important img").hover(function() {
      alert("");
    });

});
</script>
</body>

Gives the following error:

Uncaught TypeError: Object # has no method 'hover'

Usually this error is caused by a missing $ but not in this case?

EDIT: here's how the foundation 4 html looks like at the end of body:

<script>
document.write('<script src=' +
('__proto__' in {} ? 'js/vendor/zepto' : 'js/vendor/jquery') +
'.js><\/script>')
</script>
<script src="js/foundation.min.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.alerts.js"></script>
<script src="js/foundation/foundation.clearing.js"></script>
<script src="js/foundation/foundation.cookie.js"></script>
<script src="js/foundation/foundation.dropdown.js"></script>
<script src="js/foundation/foundation.forms.js"></script>
<script src="js/foundation/foundation.joyride.js"></script>
<script src="js/foundation/foundation.magellan.js"></script>
<script src="js/foundation/foundation.orbit.js"></script>
<script src="js/foundation/foundation.placeholder.js"></script>
<script src="js/foundation/foundation.reveal.js"></script>
<script src="js/foundation/foundation.section.js"></script>
<script src="js/foundation/foundation.tooltips.js"></script>
<script src="js/foundation/foundation.topbar.js"></script>
<script>
$(document).foundation();
</script>

EDIT 2: Solution

Solved this by including jQuery in the head:

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Lorem Ipsum</title>
<link rel="stylesheet" href="css/foundation.min.css" />
<script src="js/vendor/jquery.js"></script>
<script src="js/vendor/custom.modernizr.js"></script>

The actual jQuery code is the same:

<script>
$(document).ready(function(){

    $("#important img").hover(function() {
      alert("");
    });

});
</script>
</body>

Protecting Source Code in Matlab vs. Python

I need to write a program in either Python or MATLAB that contains some proprietary information, but will not easily reveal this proprietary information if the program is distributed.

While I realize that a determined hacker can reverse engineer any source code, would it be easier to secure code written in Python or MATLAB?

4

1 回答 1

2

其他一些库可能会使用$,这意味着它可能会覆盖 jQuery 的$实例。因此,当您使用 时$,它指的是另一个库,它似乎没有该.hover()方法。

您可以使用jQuery而不是$引用 jQuery 库,或者使用jQuery.noConflict();使 jQuery 库在不同的变量中可访问 - http://api.jquery.com/jQuery.noConflict/

当然,请确保在页面中包含 jQuery 库:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

否则jQuery甚至不会被定义。

于 2013-05-09T14:53:08.993 回答