jQWidgets jqxWindow setTitle() 方法

  • Post category:jquery

下面我来详细讲解一下“jQWidgets jqxWindow setTitle() 方法”的完整攻略。

什么是 jQWidgets jqxWindow setTitle() 方法?

jQWidgets jqxWindow setTitle() 方法jQWidgets库中用于设置jqxWindow组件的标题文本的方法。

方法语法

该方法的语法如下:

SetTitle(title: String): void;

其中,

  • title:表示要设置的标题文本。

示例说明

下面是两个示例说明:

示例一

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>jQWidgets jqxWindow setTitle() 方法的示例一</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/jqxwindow.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#myWindow').jqxWindow({
                height: 300,
                width: 400,
                autoOpen: true
            });
            $('#myButton').click(function () {
                $('#myWindow').jqxWindow('setTitle', '新标题');
            });
        });
    </script>
</head>
<body>
    <div id="myButton">点击我设置标题</div>
    <div id="myWindow">
        <div>窗口内容</div>
    </div>
</body>
</html>

该示例演示了如何创建一个jqxWindow组件,并且在点击按钮时,通过调用setTitle()方法修改窗口的标题文本。

示例二

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>jQWidgets jqxWindow setTitle() 方法的示例二</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/4.3.0/jqwidgets/jqxwindow.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#myWindow').jqxWindow({
                height: 300,
                width: 400,
                autoOpen: true
            });
            $('#myWindow').jqxWindow('setTitle', '新标题');
        });
    </script>
</head>
<body>
    <div id="myWindow">
        <div>窗口内容</div>
    </div>
</body>
</html>

该示例演示了如何创建一个jqxWindow组件,并在初始化时调用setTitle()方法设置窗口的标题文本。

以上两个示例可以帮助我们理解和应用jQWidgets jqxWindow setTitle() 方法