在这篇文章中,我们将为您详细介绍html节点属性操作的内容,并且讨论关于html节点类型的相关问题。此外,我们还会涉及一些关于ajax动态增加html节点时,jqm样式未加载出来,须实现refresh
在这篇文章中,我们将为您详细介绍html节点属性操作的内容,并且讨论关于html节点类型的相关问题。此外,我们还会涉及一些关于ajax动态增加html节点时,jqm样式未加载出来,须实现refresh操作、C# XML文件创建保存、子节点及属性操作、C#通过XML节点属性/属性值读取写入XML操作代码实例、DOM下的节点属性和操作小结的知识,以帮助您更全面地了解这个主题。
本文目录一览:- html节点属性操作(html节点类型)
- ajax动态增加html节点时,jqm样式未加载出来,须实现refresh操作
- C# XML文件创建保存、子节点及属性操作
- C#通过XML节点属性/属性值读取写入XML操作代码实例
- DOM下的节点属性和操作小结
html节点属性操作(html节点类型)
<div>
new document
Meta
Meta
调用js程序
函数,不能单独定义,也不能单独调用
函数只能作为数据传给其他变量
irstChild;
属性
属性
属性
属性
属性
<span>/<span>匿名函数调用和作为数据
//给变量赋不同的值,则变量就是不同类型
//给变量赋一个函数,则变量就是函数型
var a="abc";
var a=[10];
var a= function(){
alert("ok");
}
//调用方法:
a();
<span>/
<span></<span>script<span>>
<span></<span>head<span>>
<span><<span>body<span>>
<span><<span>body<span>><<span>img <span>onclick<span>="removeImg(this)" <span>/></<span>body<span>>
<span></<span>body<span>>
<span></<span>html<span>>
ajax动态增加html节点时,jqm样式未加载出来,须实现refresh操作
在使用js或者jQuery获取控件(例如:button、checkBox、radiobutton等)的值时,也是需要先刷新,否则无法获取到最新的值。
下面列出常用的标签的refresh操作,其他的可以举一反三。
1. Listview的refresh操作:
$('#mylistid').listview('refresh');
2. select menu的refresh操作:
var myselect = $("#myselect");
myselect[0].selectedindex = 2;
myselect.selectmenu("refresh");
3. CheckBoxes的refresh操作:
$("#mycheckBoxid").attr("checked",true).checkBoxradio("refresh");
4. Radio buttons的refresh操作:
$("#myradioid").attr("checked",true).checkBoxradio("refresh");
1.Textarea fields
$('body').prepend('<textareaid="myTextArea"></textarea>'); $('#myTextArea').textinput();
2.Text input fields
$('body').prepend('<inputtype="text"id="myTextField"/>'); $('#myTextField').textinput();
3.Buttons
$('body').append('<ahref=""data-theme="e"id="myNewButton">testing</a>'); $('#myNewButton').button();
4.ComboBox or select dropdowns
<labelfor="sCountry">Country:</label> <selectname="sCountry"id="sCountry"> <optionvalue="">WhereYouLive:</option> <optionvalue="ad">Andorra</option> <optionvalue="ae">UnitedarabEmirates</option> </select> varmyselect=$("#sCountry"); myselect[0].selectedindex=3; myselect.selectmenu('refresh');
5.Listviews
<ulid="myList"data-role="listview"data-inset="true"> <li>Acura</li> <li>Audi</li> <li>BMW</li> </ul> $('#mylist').listview('refresh');
6.Slider control
<divdata-role="fieldcontain"> <labelfor="slider-2">Inputslider:</label> <inputtype="range"id="slider-2"value="25"min="0"max="100"/> </div> $('#slider-2').val(80).slider('refresh');
7.Toggle switch
<divdata-role="fieldcontain"> <labelfor="toggle">Flipswitch:</label> <selectname="toggle"id="toggle"data-role="slider"> <optionvalue="off">Off</option> <optionvalue="on">On</option> </select> </div> varmyswitch=$("#toggle"); myswitch[0].selectedindex=1; myswitch.slider("refresh");
8.Radio buttons
<divdata-role="fieldcontain"> <fieldsetdata-role="controlgroup"data-type="horizontal"> <legend>Layoutview:</legend> <inputtype="radio"name="radio-view"value="list"/> <labelfor="radio-view-a">List</label> <inputtype="radio"name="radio-view"value="grid"/> <labelfor="radio-view-b">Grid</label> <inputtype="radio"name="radio-view"value="gallery"/> <labelfor="radio-view-c">gallery</label> </fieldset> </div> $("input[value=grid]").attr('checked',true).checkBoxradio('refresh');
9.CheckBoxes
<divdata-role="fieldcontain"> <fieldsetdata-role="controlgroup"> <legend>Agreetotheterms:</legend> <inputtype="checkBox"name="checkBox-1"id="checkBox-1"/> <labelfor="checkBox-1">Iagree</label> </fieldset> </div> $('#checkBox-1').attr('checked',true).checkBoxradio('refresh');
C# XML文件创建保存、子节点及属性操作
C# XML文件创建保存、子节点及属性操作
/// <summary>
/// 创建添加并保存XML文件
/// </summary>
private void CreatAndSaveXML()
{
XmlDocument xmlDoc = new XmlDocument();
XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8",null);
xmlDoc.AppendChild(xmlDec);
//添加根节点
XmlElement nodeRoot = xmlDoc.CreateElement("Templete");
xmlDoc.AppendChild(nodeRoot);
//添加新节点
XmlElement nodeTemp1 = xmlDoc.CreateElement("nodeTemp");
//添加节点数据
nodeTemp1.InnerText = "测试节点1";
//添加节点属性
nodeTemp1.SetAttribute("Attribute1", "123");
nodeTemp1.SetAttribute("Attribute2", "456");
nodeTemp1.SetAttribute("Attribute3", "789");
nodeRoot.AppendChild(nodeTemp1);
//添加新节点
XmlElement nodeTemp2 = nodeTemp1.Clone() as XmlElement;
nodeTemp1.InnerText = "测试节点2";
nodeTemp2.SetAttribute("Attribute1", "123");
nodeTemp2.SetAttribute("Attribute2", "456");
nodeTemp2.SetAttribute("Attribute3", "789");
nodeRoot.AppendChild(nodeTemp2);
xmlDoc.Save(Application.StartupPath + "\\xmlTemp.xml");
}
/// <summary>
/// 加载遍历XML文件
/// </summary>
private void LoadAndTraversal()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Application .StartupPath+ "\\xmlTemp.xml");
//读取根节点
XmlElement nodeElement = xmlDoc.SelectSingleNode("Templete") as XmlElement;
if (nodeElement != null)
{
XmlNodeList nodeList = nodeElement.ChildNodes;
//子节点遍历
if (nodeList != null && nodeList.Count > 0)
{
foreach (XmlNode nodeItem in nodeList)
{
//获取子节点属性
string att1 = (nodeItem as XmlElement).GetAttribute("Attribute1");
Console.WriteLine(att1);
}
}
}
}
C#通过XML节点属性/属性值读取写入XML操作代码实例
1.XML的内容如下:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<title>
<settings id = "0" name = "显示文字">欢迎您!智慧服务,互动体验......</settings>
<settings id = "1" name = "字体">微软雅黑</settings>
<settings id = "2" name = "颜色">Yellow</settings>
<settings id = "3" name = "字体尺寸">48</settings>
</title>
<menu>
<submu id="0" name="部门分布"/>
<submu id="1" name="宣传视频"/>
<submu id="2" name="部门宣传"/>
<submu id="3" name="会议安排"/>
</menu>
<mu1>
<submu id = "0" name = "iCentroView产品">
<video id = "0">Videos/ICV.mp4</video>
</submu>
<submu id = "1" name = "员工社区">
<video id = "0">Videos/ygsqxcp.mp4</video>
</submu>
<submu id = "2" name = "三维展示">
<video id = "0">Videos/iBaosight.mp4</video>
</submu>
<submu id = "1" name = "好生活宣传">
<video id = "0">Videos/goodlift.mp4</video>
</submu>
</mu1>
<main>Picture/main.jpg</main>
</root>
2.获得XML文档
private static string url = AppDomain.CurrentDomain.Setupinformation.ApplicationBase+"Config\\config.xml";
private XmlDocument xmlDoc;
private XmlNode root;
public static string Title;
public XMLHandler()
{
xmlDoc = new XmlDocument();
LoadConfig();
}
private void LoadConfig()
{
try
{
xmlDoc.Load(url);
root = xmlDoc.SelectSingleNode("root");
}
catch (Exception e)
{
throw e;
}
}