jQuery Mobile Textinput option()方法

jQuery Mobile Textinput option()方法

jQuery Mobile是一种基于网络的技术,用于制作可在所有智能手机、平板电脑和台式机上访问的响应式内容。

在这篇文章中,我们将使用jQuery Mobile Textinput option()方法。使用这个方法,我们可以获得,设置或更新Textinput部件的任何参数的值。我们也可以用这个方法获得所有选项的键值对。

语法:

1.如果我们需要任何选项的值,请在选项(optionName)方法中传递选项名称。optionName应该是一个字符串。

  • optionName。这是我们需要以字符串形式传递的输入,我们需要得到它的值。
  • return。我们根据选项的数据类型得到相应的回报。
var isDisabled = $( ".selector" ).textinput( "option", "disabled" );

2.通过调用不带参数的option方法,获得所有选项及其值的键值对。

  • input。我们需要调用选项方法。没有任何东西应该作为输入被传递。
  • return。我们得到所有选项的键值对的列表,即optionName – optionValue。
var options = $( ".selector" ).textinput( "option" );

3.通过调用optionName和value作为参数的option(optionName, value)来设置任何选项的值。

  • optionName。选项名称是第一个参数,是字符串类型的。
  • value。在调用该方法时,我们需要传递选项的值,它是对象类型的。
$(".selector").textinput( "option", "disabled", true );

4.要设置多个选项而不是只有一个,请调用option(options)方法,其中options是选项的列表。

  • options。它是optionName-value对的映射,用于设置与传递的值相对应的选项,它是对象类型的。
$( ".selector" ).popup( "option", { disabled: true } );

CDN链接:首先,添加你的项目需要的jQuery Mobile脚本。

<link rel=”stylesheet” href=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css”>
<script src=”https://code.jquery.com/jquery-1.10.2.min.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”></script>

例子:这个例子描述了jQuery Mobile Textinput option()方法。

<!doctype html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
    <script src=
"https://code.jquery.com/jquery-1.10.2.min.js">
    </script>
    <script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
    </script>
</head>
  
<body>
    <center>
        <div data-role="page">
            <h1 style="color:green;">
                GeeksforGeeks
            </h1>
            <h3>jQuery Mobile Textinput option() Method</h3>
            <div data-role="header">
            </div>
            <div role="main" class="ui-content" 
                 style="width: 50%;">
                <label for="GFG">Enter Text:</label>
                <textarea name="Geeks" 
                          id="GFG">
                  </textarea>
            </div>
            <input type="button" id="Button" 
                   value="Get the value">
            <div id="log"></div>
        </div>
    </center>
    <script>
        (document).ready(function () {
            ("#Button").on('click', function () {
                var a = ("#GFG")
                    .textinput("option", "disabled");
                ("#log").html('The value is: ' + a);
            });
        });
    </script>
</body>
  
</html>

输出:

jQuery Mobile Textinput option()方法

jQuery Mobile Textinput option()方法

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程