JQuery how to know out of all select which has lost focus

Paul Phoenix

I have form for which I want to apply some validations on all text fields and Select fields. I want to know when the blur event is called it is raised by which field. I am using the below given code.

$(document).ready(function() {

            $("select").blur(function() {
                // alert("ID "+,$(this).attr('id'));
                var selected = $("#tabs").tabs('option', 'active');

                var selectedTabTitle = $($("#tabs li")[selected]).text();

                skip_test(selectedTabTitle);
            });

            $("input").blur(function() {
                var selected = $("#tabs").tabs('option', 'active');

                var selectedTabTitle = $($("#tabs li")[selected]).text();
                skip_test(selectedTabTitle);
            });
        });
Matt Fellows

$(this) should always point to the element which fired the event

for example $(this).addClass("failedValidation")

Also if you can add a class to all the selects and inputs you will not need to repeat your code. If you can't you can define the function elsewhere and just refer to it in the blur()

e.g.

var doMyBlurStuff = function () {
     $(this).addClass("failedValidation")
};

$("select, input").blur(doMyBlurStuff);

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

jquery input select all on focus

分類Dev

How to know which variable has a value and which one is null?

分類Dev

How to find out which event listener has fired

分類Dev

How to know if threading.Condition.wait(timeout) has timed out or has been notified?

分類Dev

How to select div which has particular element in class?

分類Dev

check / uncheck the check box by tapping the cell in table view and how to know which cell has checked or unchecked

分類Dev

How do I know which delimiter has occurred first using awk in bash?

分類Dev

How to know which mailFolder is the Inbox?

分類Dev

Lost focus on eventListener

分類Dev

How I set the select all text in the style when textbox got focus?

分類Dev

How to know all items of a list-view has been viewed in android?

分類Dev

How do I find out which random port Docker has chosen?

分類Dev

How can I find out / print with which version of the protocol a pickle file has been generated

分類Dev

How to force a webpage to think that it is in or out focus?

分類Dev

Select image, which is in a div JQuery

分類Dev

how I can know if a input e-mail has value in with jquery?

分類Dev

How to select (everything) one row in table 1 which has another row that is the same as table 2

分類Dev

jQuery and jqxGrid - how to select all rows in jqxGrid via checkboxes

分類Dev

How to know which CharacterSet contains a given character?

分類Dev

How to know for which Master a Visio shape belongs to

分類Dev

how to know which JTextField is changed in a set of fields

分類Dev

How to know which ports are listened by certain PID?

分類Dev

How to know which utility installed a particular utility?

分類Dev

Jquery check which element has been dropped

分類Dev

How to check if a nonblocking luasocket client has lost it's connection?

分類Dev

How can I know which folders are created by which program?

分類Dev

How to know if a set of threads has finished

分類Dev

How to know when a block has been completed

分類Dev

How to know if the winform has stopped functioning/responding

Related 関連記事

  1. 1

    jquery input select all on focus

  2. 2

    How to know which variable has a value and which one is null?

  3. 3

    How to find out which event listener has fired

  4. 4

    How to know if threading.Condition.wait(timeout) has timed out or has been notified?

  5. 5

    How to select div which has particular element in class?

  6. 6

    check / uncheck the check box by tapping the cell in table view and how to know which cell has checked or unchecked

  7. 7

    How do I know which delimiter has occurred first using awk in bash?

  8. 8

    How to know which mailFolder is the Inbox?

  9. 9

    Lost focus on eventListener

  10. 10

    How I set the select all text in the style when textbox got focus?

  11. 11

    How to know all items of a list-view has been viewed in android?

  12. 12

    How do I find out which random port Docker has chosen?

  13. 13

    How can I find out / print with which version of the protocol a pickle file has been generated

  14. 14

    How to force a webpage to think that it is in or out focus?

  15. 15

    Select image, which is in a div JQuery

  16. 16

    how I can know if a input e-mail has value in with jquery?

  17. 17

    How to select (everything) one row in table 1 which has another row that is the same as table 2

  18. 18

    jQuery and jqxGrid - how to select all rows in jqxGrid via checkboxes

  19. 19

    How to know which CharacterSet contains a given character?

  20. 20

    How to know for which Master a Visio shape belongs to

  21. 21

    how to know which JTextField is changed in a set of fields

  22. 22

    How to know which ports are listened by certain PID?

  23. 23

    How to know which utility installed a particular utility?

  24. 24

    Jquery check which element has been dropped

  25. 25

    How to check if a nonblocking luasocket client has lost it's connection?

  26. 26

    How can I know which folders are created by which program?

  27. 27

    How to know if a set of threads has finished

  28. 28

    How to know when a block has been completed

  29. 29

    How to know if the winform has stopped functioning/responding

ホットタグ

アーカイブ