0
  for (r in resArray) {
      $(".results li").remove();
      var title = resArray[r]._source.title;
      var year = resArray[r]._source.year;
      var typeOfDrawing = resArray[r]._source.typeOfDrawing;
      var code = resArray[r]._source.code;
      var loctn = resArray[r]._source.location;
      var drawerNumber = resArray[r]._source.drawerNumber;

      function getURL() {
            planSearch(title);
      }
       
      items.push('<li class="reslts" onmouseover="getURL()">' + code + " " +   year + " " + loctn + " " + drawerNumber + "<br />" + title + "<br />" + typeOfDrawing + "</a></li>");
      $(".results").append(items);
      }

When I mouseover I get the error saying:

"getURL not defined"

Where am I wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
raj247
  • 381
  • 1
  • 4
  • 21
  • 1
    Your getUrl function is not defined on window scope, which is what onmouseover tries to find. Instead, use jquery .mouseover : https://api.jquery.com/mouseover/ – juvian Dec 03 '15 at 17:55
  • 1
    [Why inline attribute event handlers in html should not be used](http://stackoverflow.com/q/6941483/1048572) – Bergi Dec 03 '15 at 17:59
  • @juvian - i defined getURL in the window scope and it worked. – raj247 Dec 03 '15 at 18:15
  • @Bergi thanks for the link it is very useful.. as for now I have got it working because I have to finish it asap.. will implement it the way it is in that post later. – raj247 Dec 03 '15 at 18:17
  • 1
    @raj247: Better do it right from the beginning… And also, [don't fall for the infamous closure in a loop issue](http://stackoverflow.com/q/1451009/1048572). – Bergi Dec 03 '15 at 18:26

0 Answers0