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

How to determine whether a jquery object is input or select

coldplay.xixi
coldplay.xixiOriginal
2020-11-27 14:33:174410browse

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;);
}

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!

Statement:
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
Previous article:Whether jquery gets focusNext article:Whether jquery gets focus