0

I'am using the jquery-3.3.1.min.js version. In my code:

$(function (){
  var div= $("#btn-space");
  div.find("button:eq(0)")
    .click(function(){
      var activeElement=$("#action")
        .find("div:first").attr();
    }) ;
});

This the error I get in the console error

Typerror: e is undefined  in 
jquery-3.3.1.min.js :2:63533

I think is from the attr() function. We can see that in the librairy on Line 2: column 63533

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
hackthatos
  • 34
  • 1
  • 1
    What exactly is it that you expect the call to `.attr()` with no argument to do? – Pointy Apr 20 '19 at 15:50
  • I was about to ask the same thing @Pointy – Nate Apr 20 '19 at 15:51
  • 1
    In general, for performance reasons jQuery does not include much in the way of validity tests or nice friendly exceptions. If you feed it garbage, you get an error but it's not necessarily easy to understand exactly what's wrong. – Pointy Apr 20 '19 at 15:52
  • 1
    Their JS is minified. “e” is likely the argument name to `attr`, which expects a string of the attribute name. You didn’t provide one so the expected argument is undefined. – Nate Apr 20 '19 at 15:52
  • Why still use Jquery? For me, It's very easy to work with es6 & es7 rather than the Jquery. – Dilshan Apr 20 '19 at 16:11
  • My purpose is to obtain the attribute values of the button. This is why I did not supply any arguments. And print the variable value in the console log, or anything else. – hackthatos Apr 20 '19 at 16:13
  • `console.log(activeElement)`. I have forgetten to write it. – hackthatos Apr 20 '19 at 16:15
  • @Dilshan Realy ?? Are you saying that Es6 or Es7 deletes all the differents implementations in all browsers ? – hackthatos Apr 20 '19 at 16:27
  • @hackthatos My opinion. I'm using ReactJS library. ReactJS, Angular, Vue etc are the modern libraries and frameworks. Still jquery holds but for me 'different implementations in all browsers' is not a fair reason to use Jquery. Only my opinion. Don't be angry with me :) – Dilshan Apr 20 '19 at 16:44
  • I should write this. `$(selector).attr(attributName)` to get the attribute value. Thanks – hackthatos Apr 20 '19 at 17:23
  • This will solve your problem https://stackoverflow.com/questions/14645806/get-all-attributes-of-an-element-using-jquery The answer to your question is that you must pass value to .attr() – Hristo93 Apr 20 '19 at 17:54

0 Answers0