C
C
Cyril2018-02-28 11:26:34
css
Cyril, 2018-02-28 11:26:34

How to make the script separate for the block and not for all?

Good morning everyone! There is this script

$("form").submit(function() { //Change
    var th = $(this);
    $.ajax({
      type: "POST",
      url: "mail.php", //Change
      data: th.serialize()
    }).done(function() {
      alert("Спасибо! Мы с вами свяжемся в ближайшее время!");
      setTimeout(function() {
        // Done Functions
        th.trigger("reset");
      }, 1000);
    });
    return false;
  });

(which I found on the open spaces), but since I am not strong in knowledge of js, this script works for me for its intended purpose, sending a feedback form to the mail, and it also works for the search form on the site, tell me how to solve this problem ? you want to add it triggering only on the id / class block, and how to add a textarea there?

Bonus question :) : updated chrome and text-decoration: underline works something like this >_<, only in chrome. how to fight? https://imgur.com/a/WrI20

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Pyrkin, 2018-02-28
@cyril_b

$("#elem form").submit(function() { //Change
    var th = $(this);
    $.ajax({
      type: "POST",
      url: "mail.php", //Change
      data: th.serialize()
    }).done(function() {
      alert("Спасибо! Мы с вами свяжемся в ближайшее время!");
      setTimeout(function() {
        // Done Functions
        th.trigger("reset");
      }, 1000);
    });
    return false;
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question