Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   'function canBe(el)' el не считается за функцию (https://javascript.ru/forum/events/53004-%27function-canbe-el-%27-el-ne-schitaetsya-za-funkciyu.html)

Konstantinov 16.01.2015 21:00

'function canBe(el)' el не считается за функцию
 
function canBe(el) {
	$('#canbe').html(array[el.attr('id')]);
}


и тут понеслась Uncaught TypeError: undefined is not a function

что делать?! jquery подключён

рони 16.01.2015 21:17

Konstantinov,
ie?

рони 16.01.2015 21:25

Konstantinov,
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
   </style>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script>
$(function() {
    var array = {
        2015: "всякая фигня"
    };

    function canBe(el) {
        $("#canbe").html(array[el.attr("id")])
    }
    canBe($(".test"))
});

  </script>
</head>

<body>
<span id="canbe"></span>
<span id="2015" class="test"></span>
</body>

</html>


Часовой пояс GMT +3, время: 14:00.