Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
How do i add one more test condition to check name of an element
I want to add OR Condition to check name 'TestName2' and more

$("#body").on("change", "input[name='TestName1']", function (e) {

  // Something
});



Thanks

What I have tried:

i tried but not getting exact syntax
Posted
Updated 25-Feb-18 19:11pm

1 solution

try
<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
        $(document).ready(function () {

            $("body").on("change", "input[name='TestName1'],input[name='TestName2']", function (a, b) {
                var name = a.target.name;
                alert(name);
            });

        });
    </script>
</head>
<body> 
    <input type="text" name="TestName1" value=" " />
    <input type="text" name="TestName2" value=" " /> 

</body>
</html>
 
Share this answer
 
Comments
Member 10004269 26-Feb-18 4:22am    
Thank you Karthik
Karthik_Mahalingam 26-Feb-18 4:23am    
welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900