Home > Web Front-end > JS Tutorial > How to determine whether a jquery object is input or select

How to determine whether a jquery object is input or select

coldplay.xixi
Release: 2021-01-08 17:31:42
Original
4430 people have browsed it

How to determine whether a jquery object is input or select: first open the html editor and create a new html file; then enter the js code in the [<script>] tag in [index.html]; finally browse Just run the [index.html] page on the server. </script>

How to determine whether a jquery object is input or select

The operating environment of this tutorial: Windows 7 system, jquery version 3.2.1, Dell G3 computer.

Method to determine whether a jquery object is input or select:

1. First, open the html editor and create a new html file, for example: index.html.

How to determine whether a jquery object is input or select

2. In the <script></script> tag in index.html, enter the js code:

if ($(&#39;#a&#39;).is(&#39;input&#39;)) {
$(&#39;body&#39;).append(&#39; is input&#39;);
} else if($(&#39;#a&#39;).is(&#39;select&#39;)) {
$(&#39;body&#39;).append(&#39; is select&#39;);
}
Copy after login

How to determine whether a jquery object is input or select

3. The browser runs the index.html page, and the judgment result of the jquery object type will be output.

How to determine whether a jquery object is input or select

Related free learning recommendations: javascript (video)

The above is the detailed content of How to determine whether a jquery object is input or select. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template