jQuery - Вызывание встроенной функции

Это зависит от размера плавания SQL. Для простого "плавания", которое эквивалентно для плавания (53), необходимо использовать C# дважды. Для плавания (24) или ниже плавание C# будет достаточно, или двойное работало бы также.

5
задан Patrick Beardmore 22 August 2009 в 13:16
поделиться

2 ответа

In your second example, you've declared myfunction inside the anonymous function you're passing to .ready(). That means myfunction is a local variable, which is only in scope inside that anonymous function, and you cannot call it from anywhere else.

There are two solutions.

First, you can declare it outside (before or after) the call to .ready(). This should not cause any interference with jQuery. If it does, something else is wrong (perhaps a simple syntax error?) that we'd welcome you to bring up in a StackOverflow question.

Second, you shouldn't be using onMouseOver="" to attach event handlers (as that mixes JavaScript with HTML), so let's do away with it entirely. Replace your JavaScript with this:

$(document).ready(function() {
    $("#that-area-down-there").mouseover(function() {
        alert(2);
    });
});

And your HTML with this:

<area shape="rect" coords="171,115,516,227" id="that-area-down-there" />

(Presumably you'll want to replace that id with something more meaningful in context, of course.)

9
ответ дан 13 December 2019 в 22:12
поделиться

There are two resons why the code doesn't work. First of all you are missing a closing parenthesis in the call to the ready function, so you get a syntax error.

Second, the function that you define inside the function only exist in that scope. When you exit the function it doesn't exist any more.

Example:

$(document).ready(function(){
   function myfunction(x) {
      alert(x);
   }
   myfunction(42); // here it works
}

myfunction(-1); // here it doesn't exist

You can define the function globally from within the function like this:

$(document).ready(function(){
  myfunction = function(x) {
    alert(x);
  }
});
1
ответ дан 13 December 2019 в 22:12
поделиться
Другие вопросы по тегам:

Похожие вопросы: