Uncaught Typeerror: $(...). Attr is not a Function

Asked

Viewed 404 times

0

because it doesn’t work?

$('#chatEnvia').click(function() {
  if ($("#chatEscrita").val() !== "") {
    $.post("inc_chatEnvia.php", {
      acesso: "ok",
      msg: $("#chatEscrita").val(),
      de: $("#de").val(),
      para: $("#para").val()
    });
    $("#chatEscrita").val("");

    $("#chatEnvia").Attr('data-toggle', 'modal');
    $("#chatEnvia").Attr('data-target', '#chatVazio');

  }
});

Uncaught Typeerror: $(...). Attr is not a Function

$("#chatEnvia").Attr('data-toggle', 'modal');
$("#chatEnvia").Attr('data-target', '#chatVazio');
  • 9

    Try attr, lower-case.

  • @Victorstafusa kkkkkk It worked!... rsrs Thank you.

1 answer

2


Function calls are case sensitive, in your example, you are using ". Attr()", with uppercase letter:

 $("#chatEnvia").Attr('data-toggle', 'modal');

Try using with lower case letter:

$("#chatEnvia").attr('data-toggle', 'modal');

Documentation: http://api.jquery.com/attr/

NOTE: All jQuery functions follow a lowerCamelCase pattern, that is, the initial letter will always be lowercase. More information: https://en.wikipedia.org/wiki/Camel_case

Browser other questions tagged

You are not signed in. Login or sign up in order to post.