当前位置: 首页>>代码示例>>C#>>正文


C# CQ.Val方法代码示例

本文整理汇总了C#中CsQuery.CQ.Val方法的典型用法代码示例。如果您正苦于以下问题:C# CQ.Val方法的具体用法?C# CQ.Val怎么用?C# CQ.Val使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CsQuery.CQ的用法示例。


在下文中一共展示了CQ.Val方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TypeTests

        public void TypeTests()
        {
            ResetQunit();
            // Type
            var type = jQuery("#check2").Attr("type");
            var thrown = false;
            try
            {
                jQuery("#check2").Attr("type", "hidden");
            }
            catch
            {
                thrown = true;
            }
            Assert.IsTrue(thrown, "Exception thrown when trying to change type property");
            Assert.AreEqual(type, jQuery("#check2").Attr("type"), "Verify that you can't change the type of an input element");

            var check = document.CreateElement("input");
            thrown = true;
            try
            {
                jQuery(check).Attr("type", "checkbox");
            }
            catch
            {
                thrown = false;
            }
            Assert.IsTrue(thrown, "Exception thrown when trying to change type property");
            Assert.AreEqual("checkbox", jQuery(check).Attr("type"), "Verify that you can change the type of an input element that isn't in the DOM");


            ResetQunit();


            var jcheck = jQuery("<input />");
            thrown = false;
            try
            {
                jcheck.Attr("type", "checkbox");
            }
            catch
            {
                thrown = true;
            }
            Assert.IsFalse(thrown, "No exception thrown when trying to change type property");
            Assert.AreEqual("checkbox", jcheck.Attr("type"), "Verify that you can change the type of an input element that isn't in the DOM");

            var button = jQuery("#button");
            thrown = false;
            try
            {
                button.Attr("type", "submit");
            }
            catch
            {
                thrown = true;
            }
            Assert.IsTrue(thrown, "Exception thrown when trying to change type property");
            Assert.AreEqual("button", button.Attr("type"), "Verify that you can't change the type of a button element");

            var jradio = new CQ("<input>", "{ 'value': 'sup', 'type': 'radio' }", Dom);
            jradio = jradio.AppendTo("#testForm");
            Assert.AreEqual(jradio.Val(), "sup", "Value is not reset when type is set after value on a radio");

            // Setting attributes on svg elements (bug #3116)
            var jsvg = jQuery("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>"
                + "<circle cx='200' cy='200' r='150' />"
            + "</svg>").AppendTo("body");
            Assert.AreEqual(jsvg.Attr("cx", 100).Attr("cx"), "100", "Set attribute on svg element");
            jsvg.Remove();

        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:72,代码来源:Attribute.cs


注:本文中的CsQuery.CQ.Val方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。